@param string $roleRepository Must implement \Cartalyst\Sentinel\Roles\RoleRepositoryInterface
@param string $roleMapping Must implement \LaravelDoctrine\Fluent\EntityMapping

@return $this
960163
public function changeRoles($roleRepository, $roleMapping = null)
    {
        $this->repositories['role'] = $roleRepository;
        $this->mappings['role'] = $roleMapping ?: $this->mappings['role'];

        return $this;
    }
1196414
private function _expandRole(&$roleList, $roleName, $depth = 0)
    {
        $role = $roleList[$roleName];

        if (isset($role['marked']) && $role['marked']) {
            return;
        }

        // possible circular reference!
        if ($depth > 5) {
            throw new \Exception("Possible circular reference detected while expanding role '{$roleName}'");
        }

        if (!empty($role['grl_parents'])) {
            $parents = $this->translateToRoleNames($role['grl_parents']);

            foreach ($parents as $parent) {
                $this->_expandRole($roleList, $parent, $depth + 1);
            }
        } else {
            $parents = array();
        }

        $this->_acl->addRole(new \Zend_Acl_Role($role['grl_name']), $parents);

        $privileges = array_filter(array_map('trim', explode(",", $role['grl_privileges'])));
        if ($privileges) {
            $this->_acl->addPrivilege($role['grl_name'], $privileges);
        }

        $roleList[$roleName]['marked'] = true;
    }
537924
public function findByRoleId($roleId)
    {
        $select = $this->getSelect($this->getUserTableName());
        $select->where(array($this->getTableName() . '.role_id' => $roleId));
        $select->join(
            $this->getTableName(),
            $this->getTableName(). '.user_id = ' . $this->getUserTableName(). '.user_id',
            array(),
            Select::JOIN_INNER
        );
        $select->group($this->getUserTableName(). '.user_id');

        $entityPrototype = $this->getZfcUserOptions()->getUserEntityClass();

        return $this->select($select, new $entityPrototype, $this->getZfcUserHydrator());
    }
1191852
public function addRole(RoleInterface $role)
    {
        $this->roles->add($role);

        if ($role->hasUser($this) === false)
            $role->addUser($this);

        return $this;
    }
1353211
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role)
    {
        $dql = "
            SELECT rights, role, resource
            FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights
            JOIN rights.resourceNode resource
            JOIN rights.role role
            WHERE resource.path LIKE :path AND role.name = :roleName
        ";

        $query = $this->_em->createQuery($dql);
        $query->setParameter('path', $resource->getPath().'%');
        $query->setParameter('roleName', $role->getName());

        return $query->getResult();
    }
412967
public function findRoleByKey($roleKey)
    {
        if ($roleKey instanceof RoleInterface) {
            return $roleKey;
        }

        $result         =   $this->roleProvider->findByKey($roleKey);
        if ($result) {
            return $result;
        }

        $exceptionMessage   =   "The role '%(rolekey)s' cannot be found.";

        throw new RoleNotFound(isprintf($exceptionMessage, compact('roleKey')));
    }
1096432
private function prepareIncludedRoles (array $roleCollection)
    {
        $roleHelper = new RoleNameHelper();

        foreach ($roleCollection as $role => &$configuration)
        {
            try
            {
                if (!isset($configuration["included_roles"]) || !is_array($configuration["included_roles"]))
                {
                    continue;
                }

                $configuration["included_roles"] = array_map(
                    function ($includedRole) use ($roleHelper, $roleCollection, $role)
                    {
                        $normalizedRoleName = $roleHelper->normalizeRoleName($includedRole);

                        if (!isset($roleCollection[$normalizedRoleName]))
                        {
                            throw new UnknownRoleException("The included role „{$normalizedRoleName}” (in the definition of role “{$role}”) was not found.");
                        }

                        return $normalizedRoleName;
                    },
                    $configuration["included_roles"]
                );
            }
            catch (\InvalidArgumentException $e)
            {
                throw new EmptyRoleNameException("Role name could not be normalized: {$e->getMessage()}.", 0, $e);
            }
        }

        return $roleCollection;
    }
848753
public function store(RoleRequest $request)
    {
        // Create the role
        $role = Role::create($request->all());

        // Sync permissions
        $permission_ids = $request->get('permission_id', []);
        $role->permissions()->sync($permission_ids);

        return redirect()->action('\Aginev\Acl\Http\Controllers\RoleController@index')
                         ->with('success', trans('acl::role.create.created'));
    }
60812
private function addRole(Group $group, $roleData)
    {
        if (isset($roleData['id'])) {
            $role = $this->get('sulu.repository.role')->findRoleById($roleData['id']);

            if (!$role) {
                throw new EntityNotFoundException($this->get('sulu.repository.role')->getClassName(), $roleData['id']);
            }

            if (!$group->getRoles()->contains($role)) {
                $group->addRole($role);
            }
        }

        return true;
    }
121315
public function addRole(\Amulen\UserBundle\Entity\Role $role)
    {
        $this->roles[] = $role;

        return $this;
    }
1078139
public function role_mappings($rolemappings, $roles) {
        $roles[0] = get_string('none');
        $output  = html_writer::start_tag('div', array('class' => 'restore-rolemappings'));
        $output .= $this->output->heading(get_string('restorerolemappings', 'backup'), 2);
        foreach ($rolemappings as $id => $mapping) {
            $label = $mapping->name;
            $name = 'mapping'.$id;
            $selected = $mapping->targetroleid;
            $output .= $this->backup_detail_select($label, $name, $roles, $mapping->targetroleid, false, array(), $mapping->description);
        }
        $output .= html_writer::end_tag('div');
        return $output;
    }
633875
public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof RoleQuery) {
            return $criteria;
        }
        $query = new RoleQuery(null, null, $modelAlias);

        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }
272953
public function initializeRoleLimitAction(Role $role)
    {
        $this->roleManager->initializeLimit($role);

        return new JsonResponse(
            array(
                'name' => $role->getName(),
                'limit' => $role->getMaxUsers(),
                'translationKey' => $role->getTranslationKey()
            )
        );
    }
651258
public void map(final User user, final Role role)
    {
        this.getRoleMappings().add(new RoleMapping(user, role));
    }
743083
public function loadRoleDraftByRoleId($roleId)
    {
        $query = $this->handler->createSelectQuery();
        $query->select(
            $this->handler->aliasedColumn($query, 'id', 'ezrole'),
            $this->handler->aliasedColumn($query, 'name', 'ezrole'),
            $this->handler->aliasedColumn($query, 'version', 'ezrole'),
            $this->handler->aliasedColumn($query, 'id', 'ezpolicy'),
            $this->handler->aliasedColumn($query, 'function_name', 'ezpolicy'),
            $this->handler->aliasedColumn($query, 'module_name', 'ezpolicy'),
            $this->handler->aliasedColumn($query, 'original_id', 'ezpolicy'),
            $this->handler->aliasedColumn($query, 'identifier', 'ezpolicy_limitation'),
            $this->handler->aliasedColumn($query, 'value', 'ezpolicy_limitation_value')
        )->from(
            $this->handler->quoteTable('ezrole')
        )->leftJoin(
            $this->handler->quoteTable('ezpolicy'),
            $query->expr->eq(
                $this->handler->quoteColumn('role_id', 'ezpolicy'),
                $this->handler->quoteColumn('id', 'ezrole')
            )
        )->leftJoin(
            $this->handler->quoteTable('ezpolicy_limitation'),
            $query->expr->eq(
                $this->handler->quoteColumn('policy_id', 'ezpolicy_limitation'),
                $this->handler->quoteColumn('id', 'ezpolicy')
            )
        )->leftJoin(
            $this->handler->quoteTable('ezpolicy_limitation_value'),
            $query->expr->eq(
                $this->handler->quoteColumn('limitation_id', 'ezpolicy_limitation_value'),
                $this->handler->quoteColumn('id', 'ezpolicy_limitation')
            )
        )->where(
            $query->expr->eq(
                // Column name "version" is misleading as it stores originalId when creating a draft from an existing role.
                // But hey, this is legacy! :-)
                $this->handler->quoteColumn('version', 'ezrole'),
                $query->bindValue($roleId, null, \PDO::PARAM_STR)
            )
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
1278650
public void map(final Group group, final Role role)
    {
        try
        {
            this.addRoleMapping(new RoleMapping(group, role));
        }
        catch(final RepositoryException e)
        {
            throw new RuntimeException("Found unexpected exception while adding role mapping", e);
        }
    }
382686
public void map(final RestletUtilUser user, final Role role)
    {
        try
        {
            this.addRoleMapping(new RoleMapping(user, role));
        }
        catch(final RepositoryException e)
        {
            throw new RuntimeException("Found unexpected exception while adding role mapping", e);
        }
    }