public function getEnv($envId)
{
/* @var $env Account\Environment */
$env = Account\Environment::findOne(array_merge($this->getDefaultCriteria(), [['id' => $envId]]));
if (!$env) {
throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Environment either does not exist or is not owned by your account.");
}
if (!$this->getUser()->hasAccessToEnvironment($envId)) {
//Checks entity level write access permissions
throw new ApiErrorException(403, ErrorMessage::ERR_PERMISSION_VIOLATION, "Insufficient permissions");
}
return $env;
}