eZPublishCommunityProject  2013.6
eZ\Publish\Core\Repository\RoleService Class Reference
+ Inheritance diagram for eZ\Publish\Core\Repository\RoleService:
+ Collaboration diagram for eZ\Publish\Core\Repository\RoleService:

Public Member Functions

 __construct (RepositoryInterface $repository, Handler $userHandler, array $settings=array())
 Setups service with reference to repository object that created it & corresponding handler. More...
 
 addPolicy (APIRole $role, APIPolicyCreateStruct $policyCreateStruct)
 Adds a new policy to the role. More...
 
 assignRoleToUser (APIRole $role, User $user, RoleLimitation $roleLimitation=null)
 Assigns a role to the given user. More...
 
 assignRoleToUserGroup (APIRole $role, UserGroup $userGroup, RoleLimitation $roleLimitation=null)
 Assigns a role to the given user group. More...
 
 buildDomainPolicyObject (SPIPolicy $policy, SPIRole $role=null)
 Maps provided SPI Policy value object to API Policy value object. More...
 
 buildDomainUserGroupRoleAssignmentObject (SPIRoleAssignment $spiRoleAssignment, UserGroup $userGroup=null, APIRole $role=null)
 Builds the API UserGroupRoleAssignment object from provided SPI RoleAssignment object. More...
 
 buildDomainUserRoleAssignmentObject (SPIRoleAssignment $spiRoleAssignment, User $user=null, APIRole $role=null)
 Builds the API UserRoleAssignment object from provided SPI RoleAssignment object. More...
 
 createRole (APIRoleCreateStruct $roleCreateStruct)
 Creates a new Role. More...
 
 deleteRole (APIRole $role)
 Deletes the given role. 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...
 
 getRoleAssignments (APIRole $role)
 Returns the assigned user and user groups to this role. More...
 
 getRoleAssignmentsForUser (User $user, $inherited=false)
 Returns the roles assigned to the given user. More...
 
 getRoleAssignmentsForUserGroup (UserGroup $userGroup)
 Returns the roles assigned to the given user group. More...
 
 loadPoliciesByUserId ($userId)
 Loads all policies from roles which are assigned to a user or to user groups to which the user belongs. 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. More...
 
 newPolicyCreateStruct ($module, $function)
 Instantiates a policy create class. More...
 
 newPolicyUpdateStruct ()
 Instantiates a policy update class. More...
 
 newRoleCreateStruct ($name)
 Instantiates a role create class. More...
 
 newRoleUpdateStruct ()
 Instantiates a policy update class. More...
 
 removePolicy (APIRole $role, APIPolicy $policy)
 removes a policy from the role More...
 
 unassignRoleFromUser (APIRole $role, User $user)
 removes a role from the given user. More...
 
 unassignRoleFromUserGroup (APIRole $role, UserGroup $userGroup)
 removes a role from the given user group. More...
 
 updatePolicy (APIPolicy $policy, APIPolicyUpdateStruct $policyUpdateStruct)
 Updates the limitations of a policy. More...
 
 updateRole (APIRole $role, RoleUpdateStruct $roleUpdateStruct)
 Updates the name of the role. More...
 
- Public Member Functions inherited from eZ\Publish\API\Repository\RoleService
 addPolicy (Role $role, PolicyCreateStruct $policyCreateStruct)
 Adds a new policy to the role. More...
 
 assignRoleToUser (Role $role, User $user, RoleLimitation $roleLimitation=null)
 Assigns a role to the given user. More...
 
 assignRoleToUserGroup (Role $role, UserGroup $userGroup, RoleLimitation $roleLimitation=null)
 Assigns a role to the given user group. More...
 
 createRole (RoleCreateStruct $roleCreateStruct)
 Creates a new Role. More...
 
 deleteRole (Role $role)
 Deletes the given role. More...
 
 getRoleAssignments (Role $role)
 Returns the assigned user and user groups to this role. More...
 
 getRoleAssignmentsForUser (User $user)
 Returns the roles assigned to the given user. More...
 
 removePolicy (Role $role, Policy $policy)
 removes a policy from the role More...
 
 unassignRoleFromUser (Role $role, User $user)
 removes a role from the given user. More...
 
 unassignRoleFromUserGroup (Role $role, UserGroup $userGroup)
 removes a role from the given user group. More...
 
 updatePolicy (Policy $policy, PolicyUpdateStruct $policyUpdateStruct)
 Updates the limitations of a policy. More...
 
 updateRole (Role $role, RoleUpdateStruct $roleUpdateStruct)
 Updates the name of the role. More...
 

Protected Member Functions

 buildDomainRoleObject (SPIRole $role)
 Maps provided SPI Role value object to API Role value object. More...
 
 buildPersistencePolicyObject ($module, $function, array $limitations)
 Creates SPI Policy value object from provided module, function and limitations. More...
 
 buildPersistenceRoleObject (APIRoleCreateStruct $roleCreateStruct)
 Creates SPI Role value object from provided API role create struct. More...
 

Protected Attributes

 $repository
 
 $settings
 
 $userHandler
 

Constructor & Destructor Documentation

eZ\Publish\Core\Repository\RoleService::__construct ( RepositoryInterface  $repository,
Handler  $userHandler,
array  $settings = array() 
)

Setups service with reference to repository object that created it & corresponding handler.

Parameters
\eZ\Publish\API\Repository\Repository$repository
\eZ\Publish\SPI\Persistence\User\Handler$userHandler
array$settings

Member Function Documentation

eZ\Publish\Core\Repository\RoleService::addPolicy ( APIRole  $role,
APIPolicyCreateStruct  $policyCreateStruct 
)

Adds a new policy to the role.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to add a policy
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\PolicyCreateStruct$policyCreateStruct
Returns
eZ\Publish\Core\Repository\RoleService::assignRoleToUser ( APIRole  $role,
User  $user,
RoleLimitation  $roleLimitation = null 
)

Assigns a role to the given user.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to assign a role
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\User$user
\eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation$roleLimitationan optional role limitation (which is either a subtree limitation or section limitation)
eZ\Publish\Core\Repository\RoleService::assignRoleToUserGroup ( APIRole  $role,
UserGroup  $userGroup,
RoleLimitation  $roleLimitation = null 
)

Assigns a role to the given user group.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to assign a role
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
\eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation$roleLimitationan optional role limitation (which is either a subtree limitation or section limitation)
eZ\Publish\Core\Repository\RoleService::buildDomainPolicyObject ( SPIPolicy  $policy,
SPIRole  $role = null 
)

Maps provided SPI Policy value object to API Policy value object.

private Only accessible for other services and the internals of the repository

Parameters
\eZ\Publish\SPI\Persistence\User\Policy$policy
\eZ\Publish\SPI\Persistence\User\Role | null$role
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\buildDomainRoleObject(), eZ\Publish\Core\Repository\RoleService\loadPoliciesByUserId(), and eZ\Publish\Core\Repository\RoleService\updatePolicy().

eZ\Publish\Core\Repository\RoleService::buildDomainRoleObject ( SPIRole  $role)
protected

Maps provided SPI Role value object to API Role value object.

Parameters
\eZ\Publish\SPI\Persistence\User\Role$role
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\createRole(), eZ\Publish\Core\Repository\RoleService\loadRole(), eZ\Publish\Core\Repository\RoleService\loadRoleByIdentifier(), and eZ\Publish\Core\Repository\RoleService\loadRoles().

eZ\Publish\Core\Repository\RoleService::buildDomainUserGroupRoleAssignmentObject ( SPIRoleAssignment  $spiRoleAssignment,
UserGroup  $userGroup = null,
APIRole  $role = null 
)

Builds the API UserGroupRoleAssignment object from provided SPI RoleAssignment object.

Parameters
\eZ\Publish\SPI\Persistence\User\RoleAssignment$spiRoleAssignment
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
\eZ\Publish\API\Repository\Values\User\Role$role
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\getRoleAssignments(), eZ\Publish\Core\Repository\RoleService\getRoleAssignmentsForUser(), and eZ\Publish\Core\Repository\RoleService\getRoleAssignmentsForUserGroup().

eZ\Publish\Core\Repository\RoleService::buildDomainUserRoleAssignmentObject ( SPIRoleAssignment  $spiRoleAssignment,
User  $user = null,
APIRole  $role = null 
)

Builds the API UserRoleAssignment object from provided SPI RoleAssignment object.

Parameters
\eZ\Publish\SPI\Persistence\User\RoleAssignment$spiRoleAssignment
\eZ\Publish\API\Repository\Values\User\User$user
\eZ\Publish\API\Repository\Values\User\Role$role
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\getRoleAssignments(), and eZ\Publish\Core\Repository\RoleService\getRoleAssignmentsForUser().

eZ\Publish\Core\Repository\RoleService::buildPersistencePolicyObject (   $module,
  $function,
array  $limitations 
)
protected

Creates SPI Policy value object from provided module, function and limitations.

validateLimitation()

Parameters
string$module
string$function
\eZ\Publish\API\Repository\Values\User\Limitation[]$limitations
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\addPolicy(), eZ\Publish\Core\Repository\RoleService\buildPersistenceRoleObject(), and eZ\Publish\Core\Repository\RoleService\updatePolicy().

eZ\Publish\Core\Repository\RoleService::buildPersistenceRoleObject ( APIRoleCreateStruct  $roleCreateStruct)
protected

Creates SPI Role value object from provided API role create struct.

buildPersistencePolicyObject()

Parameters
\eZ\Publish\API\Repository\Values\User\RoleCreateStruct$roleCreateStruct
Returns

Referenced by eZ\Publish\Core\Repository\RoleService\createRole().

eZ\Publish\Core\Repository\RoleService::createRole ( APIRoleCreateStruct  $roleCreateStruct)

Creates a new Role.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to create a role
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the name of the role already exists
Parameters
\eZ\Publish\API\Repository\Values\User\RoleCreateStruct$roleCreateStruct
Returns
eZ\Publish\Core\Repository\RoleService::deleteRole ( APIRole  $role)

Deletes the given role.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to delete this role
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
eZ\Publish\Core\Repository\RoleService::getLimitationType (   $identifier)

Returns the LimitationType registered with the given identifier.

Returns the correct implementation of API Limitation value object based on provided identifier

Parameters
string$identifier
Returns
Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionif there is no LimitationType with $identifier

Implements eZ\Publish\API\Repository\RoleService.

Referenced by eZ\Publish\Core\Repository\RoleService\buildDomainPolicyObject().

eZ\Publish\Core\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$moduleLegacy name of "controller", it's a unique identifier like "content"
string$functionLegacy name of a controller "action", it's a unique within the controller like "read"
Returns
[]
Exceptions
\eZ\Publish\API\Repository\Exceptions\BadStateExceptionIf module/function to limitation type mapping refers to a non existing identifier.

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::getRoleAssignments ( APIRole  $role)

Returns the assigned user and user groups to this role.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read a role
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
Returns
[]
eZ\Publish\Core\Repository\RoleService::getRoleAssignmentsForUser ( User  $user,
  $inherited = false 
)

Returns the roles assigned to the given user.

Parameters
\eZ\Publish\API\Repository\Values\User\User$user
boolean$inherited
Exceptions
\eZ\Publish\Core\Base\Exceptions\UnauthorizedExceptionIf the current user is not allowed to read a role
\eZ\Publish\Core\Base\Exceptions\InvalidArgumentValueOn invalid User object
Returns
[]
eZ\Publish\Core\Repository\RoleService::getRoleAssignmentsForUserGroup ( UserGroup  $userGroup)

Returns the roles assigned to the given user group.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read a role
Parameters
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
Returns
[]

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::loadPoliciesByUserId (   $userId)

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

Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionif a user with the given id was not found
Parameters
mixed$userId
Returns
[]

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::loadRole (   $id)
eZ\Publish\Core\Repository\RoleService::loadRoleByIdentifier (   $identifier)

Loads a role for the given identifier.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read this role
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionif a role with the given name was not found
Parameters
string$identifier
Returns

Implements eZ\Publish\API\Repository\RoleService.

Referenced by eZ\Publish\Core\Repository\RoleService\createRole(), and eZ\Publish\Core\Repository\RoleService\updateRole().

eZ\Publish\Core\Repository\RoleService::loadRoles ( )

Loads all roles.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to read the roles
Returns
[]

Implements eZ\Publish\API\Repository\RoleService.

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

Instantiates a policy create class.

Parameters
string$module
string$function
Returns

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::newPolicyUpdateStruct ( )

Instantiates a policy update class.

Returns

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::newRoleCreateStruct (   $name)

Instantiates a role create class.

Parameters
string$name
Returns

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::newRoleUpdateStruct ( )

Instantiates a policy update class.

Returns

Implements eZ\Publish\API\Repository\RoleService.

eZ\Publish\Core\Repository\RoleService::removePolicy ( APIRole  $role,
APIPolicy  $policy 
)

removes a policy from the role

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to remove a policy
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\Policy$policythe policy to remove from the role
Returns
the updated role
eZ\Publish\Core\Repository\RoleService::unassignRoleFromUser ( APIRole  $role,
User  $user 
)

removes a role from the given user.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to remove a role
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionIf the role is not assigned to the user
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\User$user
eZ\Publish\Core\Repository\RoleService::unassignRoleFromUserGroup ( APIRole  $role,
UserGroup  $userGroup 
)

removes a role from the given user group.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to remove a role
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionIf the role is not assigned to the given user group
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\UserGroup$userGroup
eZ\Publish\Core\Repository\RoleService::updatePolicy ( APIPolicy  $policy,
APIPolicyUpdateStruct  $policyUpdateStruct 
)

Updates the limitations of a policy.

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

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to update a policy
Parameters
\eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct$policyUpdateStruct
\eZ\Publish\API\Repository\Values\User\Policy$policy
Returns
eZ\Publish\Core\Repository\RoleService::updateRole ( APIRole  $role,
RoleUpdateStruct  $roleUpdateStruct 
)

Updates the name of the role.

Exceptions
\eZ\Publish\API\Repository\Exceptions\UnauthorizedExceptionif the authenticated user is not allowed to update a role
\eZ\Publish\API\Repository\Exceptions\InvalidArgumentExceptionif the name of the role already exists
Parameters
\eZ\Publish\API\Repository\Values\User\Role$role
\eZ\Publish\API\Repository\Values\User\RoleUpdateStruct$roleUpdateStruct
Returns

Member Data Documentation

eZ\Publish\Core\Repository\RoleService::$repository
protected
eZ\Publish\Core\Repository\RoleService::$settings
protected
eZ\Publish\Core\Repository\RoleService::$userHandler
protected

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