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

Public Member Functions | List of all members
eZ\Publish\API\Repository\RoleService Interface Reference

This service provides methods for managing Roles and Policies. More...

Inheritance diagram for eZ\Publish\API\Repository\RoleService:

## Public Member Functions
| createRole (RoleCreateStruct $roleCreateStruct)
| Creates a new RoleDraft. More...
| createRoleDraft (Role $role)
| Creates a new RoleDraft for existing Role. More...
| loadRoleDraft ($id)
| Loads a RoleDraft for the given id. More...
| loadRoleDraftByRoleId ($roleId)
| Loads a RoleDraft by the ID of the role it was created from. More...
| updateRoleDraft (RoleDraft $roleDraft, RoleUpdateStruct $roleUpdateStruct)
| Updates the properties of a RoleDraft. More...
| addPolicyByRoleDraft (RoleDraft $roleDraft, PolicyCreateStruct $policyCreateStruct)
| Adds a new policy to the RoleDraft. More...
| removePolicyByRoleDraft (RoleDraft $roleDraft, PolicyDraft $policyDraft)
| Removes a policy from a RoleDraft. More...
| updatePolicyByRoleDraft (RoleDraft $roleDraft, PolicyDraft $policy, PolicyUpdateStruct $policyUpdateStruct)
| Updates the limitations of a policy. More...
| deleteRoleDraft (RoleDraft $roleDraft)
| Deletes the given RoleDraft. More...
| publishRoleDraft (RoleDraft $roleDraft)
| Publishes the given RoleDraft. More...
| updateRole (Role $role, RoleUpdateStruct $roleUpdateStruct)
| Updates the name of the role. More...
| addPolicy (Role $role, PolicyCreateStruct $policyCreateStruct)
| Adds a new policy to the role. More...
| deletePolicy (Policy $policy)
| Deletes a policy. More...
| updatePolicy (Policy $policy, PolicyUpdateStruct $policyUpdateStruct)
| Updates the limitations of a policy. More...
| loadRole ($id)
| Loads a role for the given id. More...
| loadRoleByIdentifier ($identifier)
| Loads a role for the given identifier. More...
| loadRoles ()
| Loads all roles, excluding the ones the current user is not allowed to read. More...
| deleteRole (Role $role)
| Deletes the given role. More...
| loadPoliciesByUserId ($userId)
| Loads all policies from roles which are assigned to a user or to user groups to which the user belongs. More...
| assignRoleToUserGroup (Role $role, UserGroup $userGroup, RoleLimitation $roleLimitation=null)
| Assigns a role to the given user group. More...
| unassignRoleFromUserGroup (Role $role, UserGroup $userGroup)
| Removes a role from the given user group. More...
| assignRoleToUser (Role $role, User $user, RoleLimitation $roleLimitation=null)
| Assigns a role to the given user. More...
| unassignRoleFromUser (Role $role, User $user)
| Removes a role from the given user. More...
| loadRoleAssignment ($roleAssignmentId)
| Loads a role assignment for the given id. More...
| getRoleAssignments (Role $role)
| Returns the assigned user and user groups to this role. More...
| getRoleAssignmentsForUser (User $user, $inherited=false)
| Returns UserRoleAssignments assigned to the given User, excluding the ones the current user is not allowed to read. More...
| getRoleAssignmentsForUserGroup (UserGroup $userGroup)
| Returns the UserGroupRoleAssignments assigned to the given UserGroup, excluding the ones the current user is not allowed to read. More...
| removeRoleAssignment (RoleAssignment $roleAssignment)
| Removes the given role assignment. More...
| newRoleCreateStruct ($name)
| Instantiates a role create class. More...
| newPolicyCreateStruct ($module, $function)
| Instantiates a policy create class. More...
| newPolicyUpdateStruct ()
| Instantiates a policy update class. More...
| newRoleUpdateStruct ()
| Instantiates a policy update class. More...
| getLimitationType ($identifier)
| Returns the LimitationType registered with the given identifier. More...
| getLimitationTypesByModuleFunction ($module, $function)
| Returns the LimitationType's assigned to a given module/function. More...

## Detailed Description

This service provides methods for managing Roles and Policies.

Definition at line 25 of file API/Repository/RoleService.php.

## Member Function Documentation

## ◆ addPolicy()

eZ\Publish\API\Repository\RoleService::addPolicy | ( | Role | $role,
|  | PolicyCreateStruct | $policyCreateStruct
| ) |  |

Adds a new policy to the role.

Deprecated:
  since 6.0, use {

See also
  addPolicyByRoleDraft}

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ addPolicyByRoleDraft()

eZ\Publish\API\Repository\RoleService::addPolicyByRoleDraft | ( | RoleDraft | $roleDraft,
|  | PolicyCreateStruct | $policyCreateStruct
| ) |  |

Adds a new policy to the RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ assignRoleToUser()

eZ\Publish\API\Repository\RoleService::assignRoleToUser | ( | Role | $role,
|  | User | $user,
|  | RoleLimitation | $roleLimitation = `null`
| ) |  |

Assigns a role to the given user.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ assignRoleToUserGroup()

eZ\Publish\API\Repository\RoleService::assignRoleToUserGroup | ( | Role | $role,
|  | UserGroup | $userGroup,
|  | RoleLimitation | $roleLimitation = `null`
| ) |  |

Assigns a role to the given user group.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ createRole()

eZ\Publish\API\Repository\RoleService::createRole | ( | RoleCreateStruct | $roleCreateStruct | ) |

Creates a new RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ createRoleDraft()

eZ\Publish\API\Repository\RoleService::createRoleDraft | ( | Role | $role | ) |

Creates a new RoleDraft for existing Role.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ deletePolicy()

eZ\Publish\API\Repository\RoleService::deletePolicy | ( | Policy | $policy | ) |

Deletes a policy.

Deprecated:
  since 6.0, use removePolicyByRoleDraft() instead.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ deleteRole()

eZ\Publish\API\Repository\RoleService::deleteRole | ( | Role | $role | ) |

Deletes the given role.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ deleteRoleDraft()

eZ\Publish\API\Repository\RoleService::deleteRoleDraft | ( | RoleDraft | $roleDraft | ) |

Deletes the given RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ getLimitationType()

eZ\Publish\API\Repository\RoleService::getLimitationType | ( |  | $identifier | ) |

Returns the LimitationType registered with the given identifier.

Parameters

  string | $identifier |

Returns
  \eZ\Publish\SPI\Limitation\Type

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ getLimitationTypesByModuleFunction()

eZ\Publish\API\Repository\RoleService::getLimitationTypesByModuleFunction | ( |  | $module,
|  |  | $function
| ) |  |

Returns the LimitationType's assigned to a given module/function.

Typically used for:

- Internal validation limitation value use on Policies
- Role admin gui for editing policy limitations incl list limitation options via valueSchema()

Parameters

  string | $module | Legacy name of "controller", it's a unique identifier like "content"
  string | $function | Legacy name of a controller "action", it's a unique within the controller like "read"

Returns
  \eZ\Publish\SPI\Limitation\Type[]

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ getRoleAssignments()

eZ\Publish\API\Repository\RoleService::getRoleAssignments | ( | Role | $role | ) |

Returns the assigned user and user groups to this role.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ getRoleAssignmentsForUser()

eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser | ( | User | $user,
|  |  | $inherited = `false`
| ) |  |

Returns UserRoleAssignments assigned to the given User, excluding the ones the current user is not allowed to read.

If second parameter $inherited is true then UserGroupRoleAssignment is also returned for UserGroups User is placed in as well as those inherited from parent UserGroups.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ getRoleAssignmentsForUserGroup()

eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUserGroup | ( | UserGroup | $userGroup | ) |

Returns the UserGroupRoleAssignments assigned to the given UserGroup, excluding the ones the current user is not allowed to read.

Parameters

  \eZ\Publish\API\Repository\Values\User\UserGroup | $userGroup |

Returns
  \eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[]

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadPoliciesByUserId()

eZ\Publish\API\Repository\RoleService::loadPoliciesByUserId | ( |  | $userId | ) |

Loads all policies from roles which are assigned to a user or to user groups to which the user belongs.

Deprecated:
  Since 6.8, not currently in use as permission system needs to know about role assignment limitations.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRole()

eZ\Publish\API\Repository\RoleService::loadRole | ( |  | $id | ) |

Loads a role for the given id.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRoleAssignment()

eZ\Publish\API\Repository\RoleService::loadRoleAssignment | ( |  | $roleAssignmentId | ) |

Loads a role assignment for the given id.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRoleByIdentifier()

eZ\Publish\API\Repository\RoleService::loadRoleByIdentifier | ( |  | $identifier | ) |

Loads a role for the given identifier.

Exceptions

Implemented in eZ\Publish\Core\REST\Client\RoleService, eZ\Publish\Core\SignalSlot\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRoleDraft()

eZ\Publish\API\Repository\RoleService::loadRoleDraft | ( |  | $id | ) |

Loads a RoleDraft for the given id.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRoleDraftByRoleId()

eZ\Publish\API\Repository\RoleService::loadRoleDraftByRoleId | ( |  | $roleId | ) |

Loads a RoleDraft by the ID of the role it was created from.

Parameters

  mixed | $roleId | ID of the role the draft was created from.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ loadRoles()

eZ\Publish\API\Repository\RoleService::loadRoles | ( |  | ) |

Loads all roles, excluding the ones the current user is not allowed to read.

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

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ newPolicyCreateStruct()

eZ\Publish\API\Repository\RoleService::newPolicyCreateStruct | ( |  | $module,
|  |  | $function
| ) |  |

Instantiates a policy create class.

Parameters

  string | $module |
  string | $function |

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

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ newPolicyUpdateStruct()

eZ\Publish\API\Repository\RoleService::newPolicyUpdateStruct | ( |  | ) |

Instantiates a policy update class.

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

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ newRoleCreateStruct()

eZ\Publish\API\Repository\RoleService::newRoleCreateStruct | ( |  | $name | ) |

Instantiates a role create class.

Parameters

  string | $name |

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

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ newRoleUpdateStruct()

eZ\Publish\API\Repository\RoleService::newRoleUpdateStruct | ( |  | ) |

Instantiates a policy update class.

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

Implemented in eZ\Publish\Core\SignalSlot\RoleService, eZ\Publish\Core\REST\Client\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ publishRoleDraft()

eZ\Publish\API\Repository\RoleService::publishRoleDraft | ( | RoleDraft | $roleDraft | ) |

Publishes the given RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ removePolicyByRoleDraft()

eZ\Publish\API\Repository\RoleService::removePolicyByRoleDraft | ( | RoleDraft | $roleDraft,
|  | PolicyDraft | $policyDraft
| ) |  |

Removes a policy from a RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ removeRoleAssignment()

eZ\Publish\API\Repository\RoleService::removeRoleAssignment | ( | RoleAssignment | $roleAssignment | ) |

Removes the given role assignment.

i.e. unassigns a user or a user group from a role with the given limitations

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService, and eZ\Publish\Core\Repository\RoleService.

## ◆ unassignRoleFromUser()

eZ\Publish\API\Repository\RoleService::unassignRoleFromUser | ( | Role | $role,
|  | User | $user
| ) |  |

Removes a role from the given user.

Deprecated:
  since 6.0, use {

See also
  removeRoleAssignment} instead.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ unassignRoleFromUserGroup()

eZ\Publish\API\Repository\RoleService::unassignRoleFromUserGroup | ( | Role | $role,
|  | UserGroup | $userGroup
| ) |  |

Removes a role from the given user group.

Deprecated:
  since 6.0, use {

See also
  removeRoleAssignment} instead.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ updatePolicy()

eZ\Publish\API\Repository\RoleService::updatePolicy | ( | Policy | $policy,
|  | PolicyUpdateStruct | $policyUpdateStruct
| ) |  |

Updates the limitations of a policy.

The module and function cannot be changed and the limitations are replaced by the ones in $roleUpdateStruct.

Deprecated:
  since 6.0, use updatePolicyByRoleDraft() instead.

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ updatePolicyByRoleDraft()

eZ\Publish\API\Repository\RoleService::updatePolicyByRoleDraft | ( | RoleDraft | $roleDraft,
|  | PolicyDraft | $policy,
|  | PolicyUpdateStruct | $policyUpdateStruct
| ) |  |

Updates the limitations of a policy.

The module and function cannot be changed and the limitations are replaced by the ones in $roleUpdateStruct.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ updateRole()

eZ\Publish\API\Repository\RoleService::updateRole | ( | Role | $role,
|  | RoleUpdateStruct | $roleUpdateStruct
| ) |  |

Updates the name of the role.

Deprecated:
  since 6.0, use {

See also
  updateRoleDraft}

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

## ◆ updateRoleDraft()

eZ\Publish\API\Repository\RoleService::updateRoleDraft | ( | RoleDraft | $roleDraft,
|  | RoleUpdateStruct | $roleUpdateStruct
| ) |  |

Updates the properties of a RoleDraft.

Since
  6.0

Exceptions

Implemented in eZ\Publish\Core\SignalSlot\RoleService.

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

- API/Repository/RoleService.php

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