Class

eZ\Publish\Core\SignalSlot\UserService

class UserService implements UserService

UserService class.

Methods

__construct(UserService $service, SignalDispatcher $signalDispatcher)

Constructor.

UserGroup createUserGroup(UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup)

Creates a new user group using the data provided in the ContentCreateStruct parameter.

UserGroup loadUserGroup(mixed $id, array $prioritizedLanguages = array())

Loads a user group for the given id.

UserGroup[] loadSubUserGroups(UserGroup $userGroup, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the sub groups of a user group.

mixed[] deleteUserGroup(UserGroup $userGroup)

Removes a user group.

moveUserGroup(UserGroup $userGroup, UserGroup $newParent)

Moves the user group to another parent.

UserGroup updateUserGroup(UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)

Updates the group profile with fields and meta data.

User createUser(UserCreateStruct $userCreateStruct, array $parentGroups)

Create a new user.

User loadUser(mixed $userId, array $prioritizedLanguages = array())

Loads a user.

User loadAnonymousUser()

Loads anonymous user.

User loadUserByCredentials(string $login, string $password, array $prioritizedLanguages = array())

Loads a user for the given login and password.

User loadUserByLogin(string $login, array $prioritizedLanguages = array())

Loads a user for the given login.

User[] loadUsersByEmail(string $email, array $prioritizedLanguages = array())

Loads a user for the given email.

mixed[] deleteUser(User $user)

This method deletes a user.

User updateUser(User $user, UserUpdateStruct $userUpdateStruct)

Updates a user.

assignUserToUserGroup(User $user, UserGroup $userGroup)

Assigns a new user group to the user.

unAssignUserFromUserGroup(User $user, UserGroup $userGroup)

Removes a user group from the user.

UserGroup[] loadUserGroupsOfUser(User $user, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the user groups the user belongs to.

User[] loadUsersOfUserGroup(UserGroup $userGroup, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the users of a user group.

UserCreateStruct newUserCreateStruct(string $login, string $email, string $password, string $mainLanguageCode, ContentType $contentType = null)

Instantiate a user create class.

UserGroupCreateStruct newUserGroupCreateStruct(string $mainLanguageCode, null|ContentType $contentType = null)

Instantiate a user group create class.

UserUpdateStruct newUserUpdateStruct()

Instantiate a new user update struct.

UserGroupUpdateStruct newUserGroupUpdateStruct()

Instantiate a new user group update struct.

Details

at line 56
public __construct(UserService $service, SignalDispatcher $signalDispatcher)

Constructor.

Construct service object from aggregated service and signal dispatcher

Parameters

UserService $service
SignalDispatcher $signalDispatcher

at line 79
public UserGroup createUserGroup(UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup)

Creates a new user group using the data provided in the ContentCreateStruct parameter.

In 4.x in the content type parameter in the profile is ignored - the content type is determined via configuration and can be set to null. The returned version is published.

Parameters

UserGroupCreateStruct $userGroupCreateStruct a structure for setting all necessary data to create this user group
UserGroup $parentGroup

Return Value

UserGroup

Exceptions

UnauthorizedException if the authenticated user is not allowed to create a user group
InvalidArgumentException if the input structure has invalid data
ContentFieldValidationException if a field in the $userGroupCreateStruct is not valid
ContentValidationException if a required field is missing or set to an empty value

at line 104
public UserGroup loadUserGroup(mixed $id, array $prioritizedLanguages = array())

Loads a user group for the given id.

Parameters

mixed $id
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

UserGroup

Exceptions

UnauthorizedException if the authenticated user is not allowed to create a user group
NotFoundException if the user group with the given id was not found

at line 121
public UserGroup[] loadSubUserGroups(UserGroup $userGroup, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the sub groups of a user group.

Parameters

UserGroup $userGroup
int $offset the start offset for paging
int $limit the number of user groups returned
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

UserGroup[]

Exceptions

UnauthorizedException if the authenticated user is not allowed to read the user group

at line 135
public mixed[] deleteUserGroup(UserGroup $userGroup)

Removes a user group.

the users which are not assigned to other groups will be deleted.

Parameters

UserGroup $userGroup

Return Value

mixed[] Affected Location Id's (List of Locations of the Content that was deleted)

Exceptions

UnauthorizedException if the authenticated user is not allowed to create a user group

at line 158
public moveUserGroup(UserGroup $userGroup, UserGroup $newParent)

Moves the user group to another parent.

Parameters

UserGroup $userGroup
UserGroup $newParent

Exceptions

UnauthorizedException if the authenticated user is not allowed to move the user group

at line 189
public UserGroup updateUserGroup(UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct)

Updates the group profile with fields and meta data.

4.x: If the versionUpdateStruct is set in $userGroupUpdateStruct, this method internally creates a content draft, updates ts with the provided data and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.

Parameters

UserGroup $userGroup
UserGroupUpdateStruct $userGroupUpdateStruct

Return Value

UserGroup

Exceptions

UnauthorizedException if the authenticated user is not allowed to move the user group
ContentFieldValidationException if a field in the $userGroupUpdateStruct is not valid
ContentValidationException if a required field is set empty
InvalidArgumentException if a field value is not accepted by the field type

at line 217
public User createUser(UserCreateStruct $userCreateStruct, array $parentGroups)

Create a new user.

The created user is published by this method.

Parameters

UserCreateStruct $userCreateStruct the data used for creating the user
array $parentGroups the groups of type {@link \eZ\Publish\API\Repository\Values\User\UserGroup} which are assigned to the user after creation

Return Value

User

Exceptions

UnauthorizedException if the authenticated user is not allowed to move the user group
ContentFieldValidationException if a field in the $userCreateStruct is not valid
ContentValidationException if a required field is missing or set to an empty value
InvalidArgumentException if a field value is not accepted by the field type if a user with provided login already exists

at line 241
public User loadUser(mixed $userId, array $prioritizedLanguages = array())

Loads a user.

Parameters

mixed $userId
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

User

Exceptions

NotFoundException if a user with the given id was not found

at line 255
public User loadAnonymousUser()

Loads anonymous user.

Return Value

User

at line 274
public User loadUserByCredentials(string $login, string $password, array $prioritizedLanguages = array())

Loads a user for the given login and password.

{@inheritdoc}

Parameters

string $login
string $password the plain password
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

User

Exceptions

InvalidArgumentException if credentials are invalid
NotFoundException if a user with the given credentials was not found

at line 291
public User loadUserByLogin(string $login, array $prioritizedLanguages = array())

Loads a user for the given login.

{@inheritdoc}

Parameters

string $login
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

User

Exceptions

NotFoundException if a user with the given credentials was not found

at line 306
public User[] loadUsersByEmail(string $email, array $prioritizedLanguages = array())

Loads a user for the given email.

{@inheritdoc}

Parameters

string $email
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

User[]

at line 318
public mixed[] deleteUser(User $user)

This method deletes a user.

Parameters

User $user

Return Value

mixed[] Affected Location Id's (List of Locations of the Content that was deleted)

Exceptions

UnauthorizedException if the authenticated user is not allowed to delete the user

at line 349
public User updateUser(User $user, UserUpdateStruct $userUpdateStruct)

Updates a user.

4.x: If the versionUpdateStruct is set in the user update structure, this method internally creates a content draft, updates ts with the provided data and publishes the draft. If a draft is explicitly required, the user group can be updated via the content service methods.

Parameters

User $user
UserUpdateStruct $userUpdateStruct

Return Value

User

Exceptions

UnauthorizedException if the authenticated user is not allowed to update the user
ContentFieldValidationException if a field in the $userUpdateStruct is not valid
ContentValidationException if a required field is set empty
InvalidArgumentException if a field value is not accepted by the field type

at line 372
public assignUserToUserGroup(User $user, UserGroup $userGroup)

Assigns a new user group to the user.

Parameters

User $user
UserGroup $userGroup

Exceptions

UnauthorizedException if the authenticated user is not allowed to assign the user group to the user
InvalidArgumentException if the user is already in the given user group

at line 396
public unAssignUserFromUserGroup(User $user, UserGroup $userGroup)

Removes a user group from the user.

Parameters

User $user
UserGroup $userGroup

Exceptions

UnauthorizedException if the authenticated user is not allowed to remove the user group from the user
InvalidArgumentException if the user is not in the given user group

at line 423
public UserGroup[] loadUserGroupsOfUser(User $user, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the user groups the user belongs to.

Parameters

User $user
int $offset the start offset for paging
int $limit the number of user groups returned
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

UserGroup[]

Exceptions

UnauthorizedException if the authenticated user is not allowed read the user or user group

at line 440
public User[] loadUsersOfUserGroup(UserGroup $userGroup, int $offset, int $limit = 25, array $prioritizedLanguages = array())

Loads the users of a user group.

Parameters

UserGroup $userGroup
int $offset the start offset for paging
int $limit the number of users returned
array $prioritizedLanguages Used as prioritized language code on translated properties of returned object.

Return Value

User[]

Exceptions

UnauthorizedException if the authenticated user is not allowed to read the users or user group

at line 465
public UserCreateStruct newUserCreateStruct(string $login, string $email, string $password, string $mainLanguageCode, ContentType $contentType = null)

Instantiate a user create class.

Parameters

string $login the login of the new user
string $email the email of the new user
string $password the plain password of the new user
string $mainLanguageCode the main language for the underlying content object
ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration

Return Value

UserCreateStruct

at line 478
public UserGroupCreateStruct newUserGroupCreateStruct(string $mainLanguageCode, null|ContentType $contentType = null)

Instantiate a user group create class.

Parameters

string $mainLanguageCode The main language for the underlying content object
null|ContentType $contentType 5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration

Return Value

UserGroupCreateStruct

at line 488
public UserUpdateStruct newUserUpdateStruct()

Instantiate a new user update struct.

Return Value

UserUpdateStruct

at line 498
public UserGroupUpdateStruct newUserGroupUpdateStruct()

Instantiate a new user group update struct.

Return Value

UserGroupUpdateStruct