Example #1
0
 public function offsetSet($offset, $value)
 {
     if ($offset === 'default') {
         throw new NoPermissionsException("You cannot change default field.");
     }
     if ($offset === 'type' && isset($this->attributes['type'])) {
         throw new NoPermissionsException("You cannot change type after it set.");
     }
     if (isset($this->attributes['role_id']) && $offset == $this->attributes['role_id'] && $value !== $this->attributes['role_id']) {
         throw new NoPermissionsException("You cannot change id of role.");
     }
     if ($this->attributes['default'] && $offset === 'name') {
         throw new NoPermissionsException("You cannot change default role name.");
     }
     if ($offset === 'permissions') {
         $this->attributes['permissions'] = $this->_aclPermissions($value);
     } else {
         if ($offset === 'users') {
             $this->attributes['users'] = $this->_aclUsers($value);
         } else {
             parent::offsetSet($offset, $value);
         }
     }
 }