Example #1
0
 /**
  * Generate the role's permissions.
  *
  * @param Role  $entity
  * @param array $rawPermissions (i.e. from request)
  */
 public function setRolePermissions(Role &$entity, $rawPermissions)
 {
     if (!is_array($rawPermissions)) {
         return;
     }
     //set permissions if applicable and if the user is not an admin
     $permissions = !$entity->isAdmin() && !empty($rawPermissions) ? $this->security->generatePermissions($rawPermissions) : [];
     foreach ($permissions as $permissionEntity) {
         $entity->addPermission($permissionEntity);
     }
     $entity->setRawPermissions($rawPermissions);
 }
 /**
  * {@inheritDoc}
  */
 public function setRawPermissions(array $permissions)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setRawPermissions', array($permissions));
     return parent::setRawPermissions($permissions);
 }