Пример #1
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if (isset($this->originalAttributeValues['role']) && $this->originalAttributeValues['role'][1] > 0) {
             //copy to new object, so we can populate the old parent role as the related role.
             //otherwise it gets passed by reference. We need the old $this->role information to properly
             //utilize the roleParentBeingRemoved method.
             $role = unserialize(serialize($this));
             $role->role = Role::getById($this->originalAttributeValues['role'][1]);
             AllPermissionsOptimizationUtil::roleParentBeingRemoved($role);
             ReadPermissionsSubscriptionUtil::roleParentBeingRemoved();
             assert('$this->originalAttributeValues["role"][1] != $this->role->id');
         }
         return true;
     } else {
         return false;
     }
 }