PHP Class eZ\Publish\Core\Repository\RoleService

Inheritance: implements eZ\Publish\API\Repository\RoleService
Show file Open project: ezsystems/ezpublish-kernel

Protected Properties

Property Type Description
$limitationService eZ\Publish\Core\Repository\Helper\LimitationService
$repository eZ\Publish\API\Repository\Repository
$roleDomainMapper eZ\Publish\Core\Repository\Helper\RoleDomainMapper
$settings array
$userHandler eZ\Publish\SPI\Persistence\User\Handler

Public Methods

Method Description
__construct ( eZ\Publish\API\Repository\Repository $repository, eZ\Publish\SPI\Persistence\User\Handler $userHandler, LimitationService $limitationService, RoleDomainMapper $roleDomainMapper, array $settings = [] ) Setups service with reference to repository object that created it & corresponding handler.
addPolicy ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct ) : eZ\Publish\API\Repository\Values\User\Role Adds a new policy to the role.
addPolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft Adds a new policy to the RoleDraft.
assignRoleToUser ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\User $user, eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation = null ) Assigns a role to the given user.
assignRoleToUserGroup ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\UserGroup $userGroup, eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation = null ) Assigns a role to the given user group.
createRole ( eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft Creates a new RoleDraft.
createRoleDraft ( eZ\Publish\API\Repository\Values\User\Role $role ) : eZ\Publish\API\Repository\Values\User\RoleDraft Creates a new RoleDraft for an existing Role.
deletePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy ) Deletes a policy.
deleteRole ( eZ\Publish\API\Repository\Values\User\Role $role ) Deletes the given role.
deleteRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft ) Deletes the given RoleDraft.
getLimitationType ( string $identifier ) : eZ\Publish\SPI\Limitation\Type Returns the LimitationType registered with the given identifier.
getLimitationTypesByModuleFunction ( string $module, string $function ) : eZ\Publish\SPI\Limitation\Type[] Returns the LimitationType's assigned to a given module/function.
getRoleAssignments ( eZ\Publish\API\Repository\Values\User\Role $role ) : eZ\Publish\API\Repository\Values\User\RoleAssignment[] Returns the assigned user and user groups to this role.
getRoleAssignmentsForUser ( eZ\Publish\API\Repository\Values\User\User $user, $inherited = false )
getRoleAssignmentsForUserGroup ( eZ\Publish\API\Repository\Values\User\UserGroup $userGroup ) : eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[] Returns the roles assigned to the given user group.
loadPoliciesByUserId ( mixed $userId ) : eZ\Publish\API\Repository\Values\User\Policy[] Loads all policies from roles which are assigned to a user or to user groups to which the user belongs.
loadRole ( mixed $id ) : eZ\Publish\API\Repository\Values\User\Role Loads a role for the given id.
loadRoleAssignment ( mixed $roleAssignmentId ) : eZ\Publish\API\Repository\Values\User\RoleAssignment Loads a role assignment for the given id.
loadRoleByIdentifier ( string $identifier ) : eZ\Publish\API\Repository\Values\User\Role Loads a role for the given identifier.
loadRoleDraft ( mixed $id ) : eZ\Publish\API\Repository\Values\User\RoleDraft Loads a RoleDraft for the given id.
loadRoleDraftByRoleId ( mixed $roleId ) : eZ\Publish\API\Repository\Values\User\RoleDraft Loads a RoleDraft by the ID of the role it was created from.
loadRoles ( ) : eZ\Publish\API\Repository\Values\User\Role[] Loads all roles.
newPolicyCreateStruct ( string $module, string $function ) : eZ\Publish\API\Repository\Values\User\PolicyCreateStruct Instantiates a policy create class.
newPolicyUpdateStruct ( ) : eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct Instantiates a policy update class.
newRoleCreateStruct ( string $name ) : eZ\Publish\API\Repository\Values\User\RoleCreateStruct Instantiates a role create class.
newRoleUpdateStruct ( ) : eZ\Publish\API\Repository\Values\User\RoleUpdateStruct Instantiates a policy update class.
publishRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft ) Publishes a given RoleDraft.
removePolicy ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\Policy $policy ) : eZ\Publish\API\Repository\Values\User\Role Removes a policy from the role.
removePolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyDraft $policyDraft ) : eZ\Publish\API\Repository\Values\User\RoleDraft Removes a policy from a RoleDraft.
removeRoleAssignment ( eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment ) Removes the given role assignment.
unassignRoleFromUser ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\User $user ) removes a role from the given user.
unassignRoleFromUserGroup ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\UserGroup $userGroup ) removes a role from the given user group.
updatePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy, eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct ) : eZ\Publish\API\Repository\Values\User\Policy Updates the limitations of a policy. The module and function cannot be changed and the limitations are replaced by the ones in $roleUpdateStruct.
updatePolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyDraft $policy, eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct ) : eZ\Publish\API\Repository\Values\User\PolicyDraft Updates the limitations of a policy. The module and function cannot be changed and the limitations are replaced by the ones in $roleUpdateStruct.
updateRole ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct ) : eZ\Publish\API\Repository\Values\User\Role Updates the name of the role.
updateRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft Updates the properties of a RoleDraft.

Protected Methods

Method Description
checkAssignmentAndFilterLimitationValues ( mixed $contentId, eZ\Publish\SPI\Persistence\User\Role $spiRole, array $limitation = null ) : array[] | null Validate that assignments not already exists and filter validations against existing.
internalDeletePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy ) Deletes a policy.
validatePolicy ( string $module, string $function, array $limitations ) : ValidationError[][] Validates Policy context: Limitations on a module and function.
validateRoleCreateStruct ( eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct ) : ValidationError[][][] Validates Policies and Limitations in Role create struct.

Method Details

__construct() public method

Setups service with reference to repository object that created it & corresponding handler.
public __construct ( eZ\Publish\API\Repository\Repository $repository, eZ\Publish\SPI\Persistence\User\Handler $userHandler, LimitationService $limitationService, RoleDomainMapper $roleDomainMapper, array $settings = [] )
$repository eZ\Publish\API\Repository\Repository
$userHandler eZ\Publish\SPI\Persistence\User\Handler
$limitationService eZ\Publish\Core\Repository\Helper\LimitationService
$roleDomainMapper eZ\Publish\Core\Repository\Helper\RoleDomainMapper
$settings array

addPolicy() public method

Adds a new policy to the role.
Deprecation: since 6.0, use {@see \addPolicyByRoleDraft}
public addPolicy ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct ) : eZ\Publish\API\Repository\Values\User\Role
$role eZ\Publish\API\Repository\Values\User\Role
$policyCreateStruct eZ\Publish\API\Repository\Values\User\PolicyCreateStruct
return eZ\Publish\API\Repository\Values\User\Role

addPolicyByRoleDraft() public method

Adds a new policy to the RoleDraft.
Since: 6.0
public addPolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyCreateStruct $policyCreateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft
$policyCreateStruct eZ\Publish\API\Repository\Values\User\PolicyCreateStruct
return eZ\Publish\API\Repository\Values\User\RoleDraft

assignRoleToUser() public method

Assigns a role to the given user.
public assignRoleToUser ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\User $user, eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation = null )
$role eZ\Publish\API\Repository\Values\User\Role
$user eZ\Publish\API\Repository\Values\User\User
$roleLimitation eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation an optional role limitation (which is either a subtree limitation or section limitation)

assignRoleToUserGroup() public method

Assigns a role to the given user group.
public assignRoleToUserGroup ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\UserGroup $userGroup, eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation = null )
$role eZ\Publish\API\Repository\Values\User\Role
$userGroup eZ\Publish\API\Repository\Values\User\UserGroup
$roleLimitation eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation an optional role limitation (which is either a subtree limitation or section limitation)

checkAssignmentAndFilterLimitationValues() protected method

Validate that assignments not already exists and filter validations against existing.
protected checkAssignmentAndFilterLimitationValues ( mixed $contentId, eZ\Publish\SPI\Persistence\User\Role $spiRole, array $limitation = null ) : array[] | null
$contentId mixed
$spiRole eZ\Publish\SPI\Persistence\User\Role
$limitation array
return array[] | null Filtered version of $limitation

createRole() public method

Creates a new RoleDraft.
Since: 6.0
public createRole ( eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$roleCreateStruct eZ\Publish\API\Repository\Values\User\RoleCreateStruct
return eZ\Publish\API\Repository\Values\User\RoleDraft

createRoleDraft() public method

Creates a new RoleDraft for an existing Role.
Since: 6.0
public createRoleDraft ( eZ\Publish\API\Repository\Values\User\Role $role ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$role eZ\Publish\API\Repository\Values\User\Role
return eZ\Publish\API\Repository\Values\User\RoleDraft

deletePolicy() public method

Deletes a policy.
Deprecation: since 6.0, use {@link removePolicyByRoleDraft()} instead.
public deletePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy )
$policy eZ\Publish\API\Repository\Values\User\Policy the policy to delete

deleteRole() public method

Deletes the given role.
public deleteRole ( eZ\Publish\API\Repository\Values\User\Role $role )
$role eZ\Publish\API\Repository\Values\User\Role

deleteRoleDraft() public method

Deletes the given RoleDraft.
Since: 6.0
public deleteRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft )
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft

getLimitationType() public method

Returns the correct implementation of API Limitation value object based on provided identifier
public getLimitationType ( string $identifier ) : eZ\Publish\SPI\Limitation\Type
$identifier string
return eZ\Publish\SPI\Limitation\Type

getLimitationTypesByModuleFunction() public method

Typically used for: - Internal validation limitation value use on Policies - Role admin gui for editing policy limitations incl list limitation options via valueSchema()
public getLimitationTypesByModuleFunction ( string $module, string $function ) : eZ\Publish\SPI\Limitation\Type[]
$module string Legacy name of "controller", it's a unique identifier like "content"
$function string Legacy name of a controller "action", it's a unique within the controller like "read"
return eZ\Publish\SPI\Limitation\Type[]

getRoleAssignments() public method

Returns the assigned user and user groups to this role.
public getRoleAssignments ( eZ\Publish\API\Repository\Values\User\Role $role ) : eZ\Publish\API\Repository\Values\User\RoleAssignment[]
$role eZ\Publish\API\Repository\Values\User\Role
return eZ\Publish\API\Repository\Values\User\RoleAssignment[]

getRoleAssignmentsForUser() public method

See also: eZ\Publish\API\Repository\RoleService::getRoleAssignmentsForUser()
public getRoleAssignmentsForUser ( eZ\Publish\API\Repository\Values\User\User $user, $inherited = false )
$user eZ\Publish\API\Repository\Values\User\User

getRoleAssignmentsForUserGroup() public method

Returns the roles assigned to the given user group.
public getRoleAssignmentsForUserGroup ( eZ\Publish\API\Repository\Values\User\UserGroup $userGroup ) : eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[]
$userGroup eZ\Publish\API\Repository\Values\User\UserGroup
return eZ\Publish\API\Repository\Values\User\UserGroupRoleAssignment[]

internalDeletePolicy() protected method

Used by {@link removePolicy()} and {@link deletePolicy()}
protected internalDeletePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy )
$policy eZ\Publish\API\Repository\Values\User\Policy

loadPoliciesByUserId() public method

Loads all policies from roles which are assigned to a user or to user groups to which the user belongs.
public loadPoliciesByUserId ( mixed $userId ) : eZ\Publish\API\Repository\Values\User\Policy[]
$userId mixed
return eZ\Publish\API\Repository\Values\User\Policy[]

loadRole() public method

Loads a role for the given id.
public loadRole ( mixed $id ) : eZ\Publish\API\Repository\Values\User\Role
$id mixed
return eZ\Publish\API\Repository\Values\User\Role

loadRoleAssignment() public method

Loads a role assignment for the given id.
public loadRoleAssignment ( mixed $roleAssignmentId ) : eZ\Publish\API\Repository\Values\User\RoleAssignment
$roleAssignmentId mixed
return eZ\Publish\API\Repository\Values\User\RoleAssignment

loadRoleByIdentifier() public method

Loads a role for the given identifier.
public loadRoleByIdentifier ( string $identifier ) : eZ\Publish\API\Repository\Values\User\Role
$identifier string
return eZ\Publish\API\Repository\Values\User\Role

loadRoleDraft() public method

Loads a RoleDraft for the given id.
Since: 6.0
public loadRoleDraft ( mixed $id ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$id mixed
return eZ\Publish\API\Repository\Values\User\RoleDraft

loadRoleDraftByRoleId() public method

Loads a RoleDraft by the ID of the role it was created from.
public loadRoleDraftByRoleId ( mixed $roleId ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$roleId mixed ID of the role the draft was created from.
return eZ\Publish\API\Repository\Values\User\RoleDraft

loadRoles() public method

Loads all roles.
public loadRoles ( ) : eZ\Publish\API\Repository\Values\User\Role[]
return eZ\Publish\API\Repository\Values\User\Role[]

newPolicyCreateStruct() public method

Instantiates a policy create class.
public newPolicyCreateStruct ( string $module, string $function ) : eZ\Publish\API\Repository\Values\User\PolicyCreateStruct
$module string
$function string
return eZ\Publish\API\Repository\Values\User\PolicyCreateStruct

newPolicyUpdateStruct() public method

Instantiates a policy update class.
public newPolicyUpdateStruct ( ) : eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct
return eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct

newRoleCreateStruct() public method

Instantiates a role create class.
public newRoleCreateStruct ( string $name ) : eZ\Publish\API\Repository\Values\User\RoleCreateStruct
$name string
return eZ\Publish\API\Repository\Values\User\RoleCreateStruct

newRoleUpdateStruct() public method

Instantiates a policy update class.
public newRoleUpdateStruct ( ) : eZ\Publish\API\Repository\Values\User\RoleUpdateStruct
return eZ\Publish\API\Repository\Values\User\RoleUpdateStruct

publishRoleDraft() public method

Publishes a given RoleDraft.
Since: 6.0
public publishRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft )
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft

removePolicy() public method

Removes a policy from the role.
Deprecation: since 5.3, use {@link removePolicyByRoleDraft()} instead.
public removePolicy ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\Policy $policy ) : eZ\Publish\API\Repository\Values\User\Role
$role eZ\Publish\API\Repository\Values\User\Role
$policy eZ\Publish\API\Repository\Values\User\Policy the policy to remove from the role
return eZ\Publish\API\Repository\Values\User\Role the updated role

removePolicyByRoleDraft() public method

Removes a policy from a RoleDraft.
Since: 6.0
public removePolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyDraft $policyDraft ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft
$policyDraft eZ\Publish\API\Repository\Values\User\PolicyDraft the policy to remove from the RoleDraft
return eZ\Publish\API\Repository\Values\User\RoleDraft if the authenticated user is not allowed to remove a policy

removeRoleAssignment() public method

Removes the given role assignment.
public removeRoleAssignment ( eZ\Publish\API\Repository\Values\User\RoleAssignment $roleAssignment )
$roleAssignment eZ\Publish\API\Repository\Values\User\RoleAssignment

unassignRoleFromUser() public method

removes a role from the given user.
public unassignRoleFromUser ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\User $user )
$role eZ\Publish\API\Repository\Values\User\Role
$user eZ\Publish\API\Repository\Values\User\User

unassignRoleFromUserGroup() public method

removes a role from the given user group.
public unassignRoleFromUserGroup ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\UserGroup $userGroup )
$role eZ\Publish\API\Repository\Values\User\Role
$userGroup eZ\Publish\API\Repository\Values\User\UserGroup

updatePolicy() public method

Updates the limitations of a policy. The module and function cannot be changed and the limitations are replaced by the ones in $roleUpdateStruct.
public updatePolicy ( eZ\Publish\API\Repository\Values\User\Policy $policy, eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct ) : eZ\Publish\API\Repository\Values\User\Policy
$policy eZ\Publish\API\Repository\Values\User\Policy
$policyUpdateStruct eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct
return eZ\Publish\API\Repository\Values\User\Policy

updatePolicyByRoleDraft() public method

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
public updatePolicyByRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\PolicyDraft $policy, eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct $policyUpdateStruct ) : eZ\Publish\API\Repository\Values\User\PolicyDraft
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft
$policy eZ\Publish\API\Repository\Values\User\PolicyDraft
$policyUpdateStruct eZ\Publish\API\Repository\Values\User\PolicyUpdateStruct
return eZ\Publish\API\Repository\Values\User\PolicyDraft

updateRole() public method

Updates the name of the role.
Deprecation: since 6.0, use {@see \updateRoleDraft}
public updateRole ( eZ\Publish\API\Repository\Values\User\Role $role, eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct ) : eZ\Publish\API\Repository\Values\User\Role
$role eZ\Publish\API\Repository\Values\User\Role
$roleUpdateStruct eZ\Publish\API\Repository\Values\User\RoleUpdateStruct
return eZ\Publish\API\Repository\Values\User\Role

updateRoleDraft() public method

Updates the properties of a RoleDraft.
Since: 6.0
public updateRoleDraft ( eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft, eZ\Publish\API\Repository\Values\User\RoleUpdateStruct $roleUpdateStruct ) : eZ\Publish\API\Repository\Values\User\RoleDraft
$roleDraft eZ\Publish\API\Repository\Values\User\RoleDraft
$roleUpdateStruct eZ\Publish\API\Repository\Values\User\RoleUpdateStruct
return eZ\Publish\API\Repository\Values\User\RoleDraft

validatePolicy() protected method

Validates Policy context: Limitations on a module and function.
protected validatePolicy ( string $module, string $function, array $limitations ) : ValidationError[][]
$module string
$function string
$limitations array
return eZ\Publish\Core\FieldType\ValidationError[][]

validateRoleCreateStruct() protected method

Validates Policies and Limitations in Role create struct.
protected validateRoleCreateStruct ( eZ\Publish\API\Repository\Values\User\RoleCreateStruct $roleCreateStruct ) : ValidationError[][][]
$roleCreateStruct eZ\Publish\API\Repository\Values\User\RoleCreateStruct
return eZ\Publish\Core\FieldType\ValidationError[][][]

Property Details

$limitationService protected property

protected LimitationService,eZ\Publish\Core\Repository\Helper $limitationService
return eZ\Publish\Core\Repository\Helper\LimitationService

$repository protected property

protected Repository,eZ\Publish\API\Repository $repository
return eZ\Publish\API\Repository\Repository

$roleDomainMapper protected property

protected RoleDomainMapper,eZ\Publish\Core\Repository\Helper $roleDomainMapper
return eZ\Publish\Core\Repository\Helper\RoleDomainMapper

$settings protected property

protected array $settings
return array

$userHandler protected property

protected Handler,eZ\Publish\SPI\Persistence\User $userHandler
return eZ\Publish\SPI\Persistence\User\Handler