/** * Loads list of roles * * @return \eZ\Publish\Core\REST\Server\Values\RoleList */ public function listRoles() { $roles = array(); if ($this->request->query->has('identifier')) { try { $role = $this->roleService->loadRoleByIdentifier($this->request->query->get('identifier')); $roles[] = $role; } catch (APINotFoundException $e) { // Do nothing } } else { $offset = $this->request->query->has('offset') ? (int) $this->request->query->get('offset') : 0; $limit = $this->request->query->has('limit') ? (int) $this->request->query->get('limit') : -1; $roles = array_slice($this->roleService->loadRoles(), $offset >= 0 ? $offset : 0, $limit >= 0 ? $limit : null); } return new Values\RoleList($roles, $this->request->getPathInfo()); }
/** * Loads all roles. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to read the roles * * @return \eZ\Publish\API\Repository\Values\User\Role[] */ public function loadRoles() { return $this->service->loadRoles(); }
/** * Renders the role list. * * @return \Symfony\Component\HttpFoundation\Response */ public function listRolesAction() { $createForm = $this->createForm(new RoleCreateType()); return $this->render('eZPlatformUIBundle:Role:list_roles.html.twig', ['roles' => $this->roleService->loadRoles(), 'can_edit' => $this->isGranted(new Attribute('role', 'update')), 'can_assign' => $this->isGranted(new Attribute('role', 'assign')), 'can_create' => $this->isGranted(new Attribute('role', 'create')), 'can_delete' => $this->isGranted(new Attribute('role', 'delete')), 'create_form' => $createForm->createView()]); }