Автор: Vlad Dobrovolskiy (v.dobrovolskiy@scalr.com)
Наследование: extends Scalr\Model\Entity\GlobalVariable
Пример #1
0
 /**
  * Deletes farm role's global variable
  *
  * @param   int     $farmRoleId Numeric identifier of the Farm Role
  * @param   string  $name       Name of variable
  *
  * @return  ResultEnvelope
  *
  * @throws  ApiErrorException
  * @throws  ModelException
  */
 public function deleteVariableAction($farmRoleId, $name)
 {
     $farmRole = $this->getFarmRole($farmRoleId, null, true);
     $fetch = $this->getGlobalVariable($name, $this->getVariableInstance(), $farmRole->roleId, $farmRole->farmId, $farmRoleId);
     $variable = GlobalVariable\FarmRoleGlobalVariable::findPk($farmRoleId, $name);
     if (empty($fetch)) {
         throw new ApiErrorException(404, ErrorMessage::ERR_OBJECT_NOT_FOUND, "Requested Global Variable does not exist.");
     }
     if (empty($variable)) {
         throw new ApiErrorException(403, ErrorMessage::ERR_SCOPE_VIOLATION, "You can only delete Global Variables declared in Farm Role scope.");
     }
     $variable->delete();
     return $this->result(null);
 }