Esempio n. 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 addPermission(\Mautic\UserBundle\Entity\Permission $permissions)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addPermission', array($permissions));
     return parent::addPermission($permissions);
 }