Interface

eZ\Publish\API\Repository\UserService

interface UserService

This service provides methods for managing users and user groups.

Methods

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 42
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 55
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 69
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 82
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 92
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 110
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 126
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 138
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 149
public User loadAnonymousUser()

Loads anonymous user.

Return Value

User

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

Loads a user for the given login and password.

Since 6.1 login is case-insensitive across all storage engines and database backends, however if login is part of the password hash this method will essentially be case sensitive.

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 181
public User loadUserByLogin(string $login, array $prioritizedLanguages = array())

Loads a user for the given login.

Since 6.1 login is case-insensitive across all storage engines and database backends, like was the case with mysql before in eZ Publish 3.x/4.x/5.x.

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 196
public User[] loadUsersByEmail(string $email, array $prioritizedLanguages = array())

Loads a user for the given email.

Note: This method loads user by $email where $email might be case-insensitive on certain storage engines!

Returns an array of Users since eZ Publish has under certain circumstances allowed several users having same email in the past (by means of a configuration option).

Parameters

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

Return Value

User[]

at line 207
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 225
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 237
public assignUserToUserGroup(User $user, UserGroup $userGroup)

Assigns a new user group to the user.

If the user is already in the given user group this method does nothing.

Parameters

User $user
UserGroup $userGroup

Exceptions

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

at line 249
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
BadStateException If $userGroup is the last assigned user group

at line 263
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 277
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 290
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 300
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 307
public UserUpdateStruct newUserUpdateStruct()

Instantiate a new user update struct.

Return Value

UserUpdateStruct

at line 314
public UserGroupUpdateStruct newUserGroupUpdateStruct()

Instantiate a new user group update struct.

Return Value

UserGroupUpdateStruct