eZ\Publish\Core\Repository\Repository::getRoleService PHP Method

getRoleService() public method

Get RoleService.
public getRoleService ( ) : eZ\Publish\API\Repository\RoleService
return eZ\Publish\API\Repository\RoleService
    public function getRoleService()
    {
        if ($this->roleService !== null) {
            return $this->roleService;
        }
        $this->roleService = new RoleService($this, $this->persistenceHandler->userHandler(), $this->getLimitationService(), $this->getRoleDomainMapper(), $this->serviceSettings['role']);
        return $this->roleService;
    }

Usage Example

コード例 #1
0
 public function userIsSubscriber(User $user)
 {
     $roleService = $this->repository->getRoleService();
     return $this->repository->sudo(function (Repository $repository) use($user, $roleService) {
         foreach ($repository->getUserService()->loadUserGroupsOfUser($user) as $group) {
             foreach ($roleService->getRoleAssignmentsForUserGroup($group) as $role) {
                 if ($this->isSubscriberRole($role->role)) {
                     return true;
                 }
             }
         }
         return false;
     });
 }