Set inner acl-role

@param \Zend\Permissions\Acl\Role\RoleInterface $role
@return \User\Model\Permissions\Model
557541
public function setRole( Acl\Role\RoleInterface $role = null )
    {
        $this->role = $role;
        return $this;
    }
569749
public function getRolePermissions(Role $role)
    {
        $key = $this->getRoleKey($role);

        // If we've saved the caller permissions we don't need to fetch them again.
        if (array_key_exists($key, $this->rolePermissions)) {
            return $this->rolePermissions[$key];
        }

        $results = $this->getTable()->where('role', $role->getRoleName())->get()->toArray();

        return $this->rolePermissions[$key] = PermissionFactory::createFromData($results);
    }
121427
public function setRoles(\WobbleCode\UserBundle\Document\Role $roles)
    {
        $this->roles = $roles;

        return $this;
    }
1221673
public function addRole($role)
    {
        if (!$this->hasRole($role)) {
            $this->roles[] = strtoupper($role);
        }

        return $this;
    }
354789
public function deleteRole($role)
    {
        $params = [
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params);

        return $body;
    }
961594
public function assignRole(...$roles)
    {
        $roles = collect($roles)
            ->flatten()
            ->map(function ($role) {
                if (empty($role)) {
                    return false;
                }

                return $this->getStoredRole($role);
            })
            ->filter(function ($role) {
                return $role instanceof Role;
            })
            ->each(function ($role) {
                $this->ensureModelSharesGuard($role);
            })
            ->map->id
            ->all();

        $model = $this->getModel();

        if ($model->exists) {
            $this->roles()->sync($roles, false);
            $model->load('roles');
        } else {
            $class = \get_class($model);

            $class::saved(
                function ($object) use ($roles, $model) {
                    static $modelLastFiredOn;
                    if ($modelLastFiredOn !== null && $modelLastFiredOn === $model) {
                        return;
                    }
                    $object->roles()->sync($roles, false);
                    $object->load('roles');
                    $modelLastFiredOn = $object;
                });
        }

        $this->forgetCachedPermissions();

        return $this;
    }
1054957
public function assignRoleBySlug(string $role)
    {
        return $this->roles()->save(
            HCAclRole::where('slug', $role)->firstOrFail()
        );
    }
85952
public function setRoles($roles)
    {
        if (!is_array($roles)) {
            $roles = [$roles];
        }

        $this->roles = $roles;

        return $this;
    }
45371
protected function addPermission(RoleInterface $role, $permissionData)
    {
        $em = $this->getDoctrine()->getManager();
        $alreadyContains = false;

        if (isset($permissionData['id'])) {
            $permission = $em->getRepository(static::ENTITY_NAME_PERMISSION)->find($permissionData['id']);
            if (!$permission) {
                throw new EntityNotFoundException(static::ENTITY_NAME_PERMISSION, $permissionData['id']);
            }
            // only add if not already contains
            $alreadyContains = $role->getPermissions()->contains($permission);
        } else {
            $permission = new Permission();
            $permission->setContext($permissionData['context']);
            $permission->setPermissions(
                $this->get('sulu_security.mask_converter')
                    ->convertPermissionsToNumber($permissionData['permissions'])
            );
        }
        if (false === $alreadyContains) {
            $permission->setRole($role);
            $em->persist($permission);
            $role->addPermission($permission);
        }

        return true;
    }
130335
public function getInheritedRolePermissions(Role $role)
    {
        $permissions = $this->getPermissionsForRole($role);

        if ($inheritedRole = $role->getInheritedRole()) {
            if ($inheritedRole = $this->manager->convertRoleToObject($inheritedRole)) {
                $permissions = array_merge($permissions, $this->getInheritedRolePermissions($inheritedRole));
            }
        }

        return $permissions;
    }
654458
public function setRole($role)
    {
        $allowed_values = array('fleet_commander', 'wing_commander', 'squad_commander', 'squad_member');
        if ((!in_array($role, $allowed_values))) {
            throw new \InvalidArgumentException("Invalid value for 'role', must be one of 'fleet_commander', 'wing_commander', 'squad_commander', 'squad_member'");
        }
        $this->container['role'] = $role;

        return $this;
    }
757789
public function detachRole(...$roles)
    {
        $this->eachRole($roles, function($role) {
            if ($this->hasRole($role)) {
                $this->roles()->detach($role->id);
            }
        });

        return $this;
    }
637397
final protected function addRole(object $data, AbstractRole $role): BoundedRoleInterface
    {
        return new class ($role, $data) implements BoundedRoleInterface
        {
            use DelegatorTrait;

            public function __construct(AbstractRole $role, object $data)
            {
                if (false === $role->supports($data)) {
                    throw new InvalidArgumentException(
                        sprintf(
                            'Role "%s" does not support for current data',
                            get_class($role)
                        )
                    );
                }

                $this->attach($this->invoke($role, 'attach', $data));
            }

            /**
             * Extract data from bounded roles.
             *
             * @return object
             */
            public function extract(): object
            {
                return $this->invoke($this->getInstance(), 'extract');
            }

            /**
             * Invoke closure method from role.
             *
             * @param AbstractRole $role
             * @param string       $method
             * @param array        ...$args
             *
             * @return mixed
             */
            private function invoke(AbstractRole $role, string $method, ...$args)
            {
                $method = new ReflectionMethod(get_class($role), $method);
                $method->setAccessible(true);

                return $method->invoke($role, ...$args);
            }
        };
    }
1317783
public function grantUserRole($user, $role)
    {
        $params = [
            'user' => $user,
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_USER_GRANT, $params);

        return $body;
    }
276688
public function removeRole(string $role): PermissionManager
    {
        if (!$this->hasRole($role)) {
            throw new RoleException("Undefined role '{$role}'");
        }

        unset($this->permissions[$role]);

        return $this;
    }
1022892
public function hasRole(Role $role)
    {
        $this->initializeRoles();
        return array_key_exists($role->getIdentifier(), $this->roles);
    }
1289678
public function addRole($role, array $resources = [])
    {
        if ($role instanceof RoleInterface) {
            $this->roles[$role->getName()] = $role;
        } else {
            $role = new Role($role, $resources);
            $this->roles[$role->getName()] = $role;
        }
    }