Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
eZ\Publish\Core\REST\Server\Controller\Role Class Reference

Role controller. More...

Inheritance diagram for eZ\Publish\Core\REST\Server\Controller\Role:

## Public Member Functions
| __construct (RoleService $roleService, UserService $userService, LocationService $locationService)
| Construct controller. More...
| createRole (Request $request)
| Create new role. More...
| createRoleDraft ($roleId, Request $request)
| Creates a new RoleDraft for an existing Role. More...
| listRoles (Request $request)
| Loads list of roles. More...
| loadRole ($roleId)
| Loads role. More...
| loadRoleDraft ($roleId)
| Loads a role draft. More...
| updateRole ($roleId, Request $request)
| Updates a role. More...
| updateRoleDraft ($roleId, Request $request)
| Updates a role draft. More...
| publishRoleDraft ($roleId)
| Publishes a role draft. More...
| deleteRole ($roleId)
| Delete a role by ID. More...
| deleteRoleDraft ($roleId)
| Delete a role draft by ID. More...
| loadPolicies ($roleId, Request $request)
| Loads the policies for the role. More...
| deletePolicies ($roleId)
| Deletes all policies from a role. More...
| loadPolicy ($roleId, $policyId, Request $request)
| Loads a policy. More...
| addPolicy ($roleId, Request $request)
| Adds a policy to role. More...
| addPolicyByRoleDraft ($roleId, Request $request)
| Adds a policy to a role draft. More...
| updatePolicy ($roleId, $policyId, Request $request)
| Updates a policy. More...
| updatePolicyByRoleDraft ($roleId, $policyId, Request $request)
| Updates a policy. More...
| deletePolicy ($roleId, $policyId, Request $request)
| Delete a policy from role. More...
| removePolicyByRoleDraft ($roleId, $policyId, Request $request)
| Remove a policy from a role draft. More...
| assignRoleToUser ($userId, Request $request)
| Assigns role to user. More...
| assignRoleToUserGroup ($groupPath, Request $request)
| Assigns role to user group. More...
| unassignRoleFromUser ($userId, $roleId)
| Un-assigns role from user. More...
| unassignRoleFromUserGroup ($groupPath, $roleId)
| Un-assigns role from user group. More...
| loadRoleAssignmentsForUser ($userId)
| Loads role assignments for user. More...
| loadRoleAssignmentsForUserGroup ($groupPath)
| Loads role assignments for user group. More...
| loadRoleAssignmentForUser ($userId, $roleId, Request $request)
| Returns a role assignment to the given user. More...
| loadRoleAssignmentForUserGroup ($groupPath, $roleId, Request $request)
| Returns a role assignment to the given user group. More...
| listPoliciesForUser (Request $request)
| Search all policies which are applied to a given user. More...
Public Member Functions inherited from eZ\Publish\Core\REST\Server\Controller
| setInputDispatcher (InputDispatcher $inputDispatcher)
| setRouter (RouterInterface $router)
| setRepository (Repository $repository)
| setRequestParser (RequestParser $requestParser)

## Protected Member Functions
| mapToUpdateStruct (RoleCreateStruct $createStruct)
| Maps a RoleCreateStruct to a RoleUpdateStruct. More...
Protected Member Functions inherited from eZ\Publish\Core\REST\Server\Controller
| getMediaType (Request $request)
| Extracts the requested media type from $request. More...

## Protected Attributes
| $roleService
| $userService
| $locationService
Protected Attributes inherited from eZ\Publish\Core\REST\Server\Controller
| $inputDispatcher
| $router
| $requestParser
| $repository

## Private Member Functions
| getLastAddedPolicy ($role)
| Get the last added policy for $role. More...

## Detailed Description

Role controller.

Definition at line 30 of file Core/REST/Server/Controller/Role.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\REST\Server\Controller\Role::__construct | ( | RoleService | $roleService,
|  | UserService | $userService,
|  | LocationService | $locationService
| ) |  |

Construct controller.

Parameters

  \eZ\Publish\API\Repository\RoleService | $roleService |
  \eZ\Publish\API\Repository\UserService | $userService |
  \eZ\Publish\API\Repository\LocationService | $locationService |

Definition at line 60 of file Core/REST/Server/Controller/Role.php.

References eZ\Publish\Core\REST\Server\Controller\Role\$locationService, eZ\Publish\Core\REST\Server\Controller\Role\$roleService, and eZ\Publish\Core\REST\Server\Controller\Role\$userService.

## Member Function Documentation

## ◆ addPolicy()

eZ\Publish\Core\REST\Server\Controller\Role::addPolicy | ( |  | $roleId,
|  | Request | $request
| ) |  |

Adds a policy to role.

Parameters

  $roleId | int ID of a role or a role draft

Returns
  \eZ\Publish\Core\REST\Server\Values\CreatedPolicy

Definition at line 384 of file Core/REST/Server/Controller/Role.php.

References eZ\Publish\Core\REST\Server\Controller\Role\getLastAddedPolicy().

## ◆ addPolicyByRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::addPolicyByRoleDraft | ( |  | $roleId,
|  | Request | $request
| ) |  |

Adds a policy to a role draft.

Since
  6.2

Deprecated:
  since 6.3, use {

See also
  addPolicy}

Parameters

  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\CreatedPolicy

Definition at line 426 of file Core/REST/Server/Controller/Role.php.

References eZ\Publish\Core\REST\Server\Controller\Role\getLastAddedPolicy().

## ◆ assignRoleToUser()

eZ\Publish\Core\REST\Server\Controller\Role::assignRoleToUser | ( |  | $userId,
|  | Request | $request
| ) |  |

Assigns role to user.

Parameters

  $userId |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 660 of file Core/REST/Server/Controller/Role.php.

## ◆ assignRoleToUserGroup()

eZ\Publish\Core\REST\Server\Controller\Role::assignRoleToUserGroup | ( |  | $groupPath,
|  | Request | $request
| ) |  |

Assigns role to user group.

Parameters

  $groupPath |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 690 of file Core/REST/Server/Controller/Role.php.

## ◆ createRole()

eZ\Publish\Core\REST\Server\Controller\Role::createRole | ( | Request | $request | ) |

Create new role.

Defaults to publishing the role, but you can create a draft instead by setting the POST parameter publish=false

Returns
  \eZ\Publish\Core\REST\Server\Values\CreatedRole

Definition at line 77 of file Core/REST/Server/Controller/Role.php.

## ◆ createRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::createRoleDraft | ( |  | $roleId,
|  | Request | $request
| ) |  |

Creates a new RoleDraft for an existing Role.

Since
  6.2

Exceptions

Definition at line 135 of file Core/REST/Server/Controller/Role.php.

## ◆ deletePolicies()

eZ\Publish\Core\REST\Server\Controller\Role::deletePolicies | ( |  | $roleId | ) |

Deletes all policies from a role.

Parameters

  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\NoContent

Definition at line 344 of file Core/REST/Server/Controller/Role.php.

## ◆ deletePolicy()

eZ\Publish\Core\REST\Server\Controller\Role::deletePolicy | ( |  | $roleId,
|  |  | $policyId,
|  | Request | $request
| ) |  |

Delete a policy from role.

Parameters

  $roleId | int ID of a role or a role draft
  $policyId | int ID of a policy

Exceptions

Definition at line 578 of file Core/REST/Server/Controller/Role.php.

## ◆ deleteRole()

eZ\Publish\Core\REST\Server\Controller\Role::deleteRole | ( |  | $roleId | ) |

Delete a role by ID.

Parameters

  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\NoContent

Definition at line 296 of file Core/REST/Server/Controller/Role.php.

## ◆ deleteRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::deleteRoleDraft | ( |  | $roleId | ) |

Delete a role draft by ID.

Since
  6.2

Parameters

  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\NoContent

Definition at line 314 of file Core/REST/Server/Controller/Role.php.

## ◆ getLastAddedPolicy()

eZ\Publish\Core\REST\Server\Controller\Role::getLastAddedPolicy | ( |  | $role | ) |
| private

Get the last added policy for $role.

This is needed because the RoleService addPolicy() and addPolicyByRoleDraft() methods return the role, not the policy.

Parameters

  $role | \eZ\Publish\API\Repository\Values\User\Role

Returns
  \eZ\Publish\API\Repository\Values\User\Policy

Definition at line 461 of file Core/REST/Server/Controller/Role.php.

Referenced by eZ\Publish\Core\REST\Server\Controller\Role\addPolicy(), and eZ\Publish\Core\REST\Server\Controller\Role\addPolicyByRoleDraft().

## ◆ listPoliciesForUser()

eZ\Publish\Core\REST\Server\Controller\Role::listPoliciesForUser | ( | Request | $request | ) |

Search all policies which are applied to a given user.

Returns
  \eZ\Publish\Core\REST\Server\Values\PolicyList

Definition at line 847 of file Core/REST/Server/Controller/Role.php.

## ◆ listRoles()

eZ\Publish\Core\REST\Server\Controller\Role::listRoles | ( | Request | $request | ) |

Loads list of roles.

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleList

Definition at line 159 of file Core/REST/Server/Controller/Role.php.

## ◆ loadPolicies()

eZ\Publish\Core\REST\Server\Controller\Role::loadPolicies | ( |  | $roleId,
|  | Request | $request
| ) |  |

Loads the policies for the role.

Parameters

  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\PolicyList

Definition at line 330 of file Core/REST/Server/Controller/Role.php.

## ◆ loadPolicy()

eZ\Publish\Core\REST\Server\Controller\Role::loadPolicy | ( |  | $roleId,
|  |  | $policyId,
|  | Request | $request
| ) |  |

Loads a policy.

Parameters

  $roleId |
  $policyId |

Exceptions

Definition at line 365 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRole()

eZ\Publish\Core\REST\Server\Controller\Role::loadRole | ( |  | $roleId | ) |

Loads role.

Parameters

  $roleId |

Returns
  \eZ\Publish\API\Repository\Values\User\Role

Definition at line 190 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRoleAssignmentForUser()

eZ\Publish\Core\REST\Server\Controller\Role::loadRoleAssignmentForUser | ( |  | $userId,
|  |  | $roleId,
|  | Request | $request
| ) |  |

Returns a role assignment to the given user.

Parameters

  $userId |
  $roleId |

Exceptions

Definition at line 802 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRoleAssignmentForUserGroup()

eZ\Publish\Core\REST\Server\Controller\Role::loadRoleAssignmentForUserGroup | ( |  | $groupPath,
|  |  | $roleId,
|  | Request | $request
| ) |  |

Returns a role assignment to the given user group.

Parameters

  $groupPath |
  $roleId |

Exceptions

Definition at line 826 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRoleAssignmentsForUser()

eZ\Publish\Core\REST\Server\Controller\Role::loadRoleAssignmentsForUser | ( |  | $userId | ) |

Loads role assignments for user.

Parameters

  $userId |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 765 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRoleAssignmentsForUserGroup()

eZ\Publish\Core\REST\Server\Controller\Role::loadRoleAssignmentsForUserGroup | ( |  | $groupPath | ) |

Loads role assignments for user group.

Parameters

  $groupPath |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 781 of file Core/REST/Server/Controller/Role.php.

## ◆ loadRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::loadRoleDraft | ( |  | $roleId | ) |

Loads a role draft.

Parameters

  mixed | $roleId | Original role ID, or ID of the role draft itself

Returns
  \eZ\Publish\API\Repository\Values\User\RoleDraft

Definition at line 202 of file Core/REST/Server/Controller/Role.php.

## ◆ mapToUpdateStruct()

eZ\Publish\Core\REST\Server\Controller\Role::mapToUpdateStruct | ( | RoleCreateStruct | $createStruct | ) |
| protected

Maps a RoleCreateStruct to a RoleUpdateStruct.

Needed since both structs are encoded into the same media type on input.

Parameters

  \eZ\Publish\API\Repository\Values\User\RoleCreateStruct | $createStruct |

Returns
  \eZ\Publish\API\Repository\Values\User\RoleUpdateStruct

Definition at line 866 of file Core/REST/Server/Controller/Role.php.

Referenced by eZ\Publish\Core\REST\Server\Controller\Role\updateRoleDraft().

## ◆ publishRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::publishRoleDraft | ( |  | $roleId | ) |

Publishes a role draft.

Parameters

  mixed | $roleId | Original role ID, or ID of the role draft itself

Returns
  \eZ\Publish\Core\REST\Server\Values\PublishedRole

Definition at line 271 of file Core/REST/Server/Controller/Role.php.

## ◆ removePolicyByRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::removePolicyByRoleDraft | ( |  | $roleId,
|  |  | $policyId,
|  | Request | $request
| ) |  |

Remove a policy from a role draft.

Since
  6.2

Deprecated:
  since 6.3, use {

See also
  deletePolicy}

Parameters

  $roleId |
  $policyId |

Exceptions

Definition at line 632 of file Core/REST/Server/Controller/Role.php.

## ◆ unassignRoleFromUser()

eZ\Publish\Core\REST\Server\Controller\Role::unassignRoleFromUser | ( |  | $userId,
|  |  | $roleId
| ) |  |

Un-assigns role from user.

Parameters

  $userId |
  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 724 of file Core/REST/Server/Controller/Role.php.

## ◆ unassignRoleFromUserGroup()

eZ\Publish\Core\REST\Server\Controller\Role::unassignRoleFromUserGroup | ( |  | $groupPath,
|  |  | $roleId
| ) |  |

Un-assigns role from user group.

Parameters

  $groupPath |
  $roleId |

Returns
  \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList

Definition at line 744 of file Core/REST/Server/Controller/Role.php.

## ◆ updatePolicy()

eZ\Publish\Core\REST\Server\Controller\Role::updatePolicy | ( |  | $roleId,
|  |  | $policyId,
|  | Request | $request
| ) |  |

Updates a policy.

Parameters

  $roleId | int ID of a role or a role draft
  $policyId | int ID of a policy

Exceptions

Definition at line 485 of file Core/REST/Server/Controller/Role.php.

## ◆ updatePolicyByRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::updatePolicyByRoleDraft | ( |  | $roleId,
|  |  | $policyId,
|  | Request | $request
| ) |  |

Updates a policy.

Since
  6.2

Deprecated:
  since 6.3, use {

See also
  updatePolicy}

Parameters

  $roleId |
  $policyId |

Exceptions

Definition at line 542 of file Core/REST/Server/Controller/Role.php.

## ◆ updateRole()

eZ\Publish\Core\REST\Server\Controller\Role::updateRole | ( |  | $roleId,
|  | Request | $request
| ) |  |

Updates a role.

Parameters

  $roleId |

Returns
  \eZ\Publish\API\Repository\Values\User\Role

Definition at line 221 of file Core/REST/Server/Controller/Role.php.

## ◆ updateRoleDraft()

eZ\Publish\Core\REST\Server\Controller\Role::updateRoleDraft | ( |  | $roleId,
|  | Request | $request
| ) |  |

Updates a role draft.

Parameters

  mixed | $roleId | Original role ID, or ID of the role draft itself

Returns
  \eZ\Publish\API\Repository\Values\User\RoleDraft

Definition at line 243 of file Core/REST/Server/Controller/Role.php.

References eZ\Publish\Core\REST\Server\Controller\Role\mapToUpdateStruct().

## Member Data Documentation

## ◆ $locationService

eZ\Publish\Core\REST\Server\Controller\Role::$locationService
| protected

Definition at line 51 of file Core/REST/Server/Controller/Role.php.

Referenced by eZ\Publish\Core\REST\Server\Controller\Role\__construct().

## ◆ $roleService

eZ\Publish\Core\REST\Server\Controller\Role::$roleService
| protected

Definition at line 37 of file Core/REST/Server/Controller/Role.php.

Referenced by eZ\Publish\Core\REST\Server\Controller\Role\__construct().

## ◆ $userService

eZ\Publish\Core\REST\Server\Controller\Role::$userService
| protected

Definition at line 44 of file Core/REST/Server/Controller/Role.php.

Referenced by eZ\Publish\Core\REST\Server\Controller\Role\__construct().

The documentation for this class was generated from the following file:

- Core/REST/Server/Controller/Role.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.