Copied!

UserService

UserService.php : 26

This service provides methods for managing users and user groups.

Methods

publicassignUserToUserGroup()

UserService.php : 288

Assigns a new user group to the user.

public assignUserToUserGroup(User $user, UserGroup $userGroup) : void

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

Parameters

Name Type Default value Description
$user User - -
$userGroup UserGroup - -
Tags
Throws
UnauthorizedException

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

publiccheckUserCredentials()

UserService.php : 179

Checks if credentials are valid for provided User.

public checkUserCredentials(User $user, string $credentials) : bool

Parameters

Name Type Default value Description
$user User - -
$credentials string - -

Return values

bool

publiccreateUser()

UserService.php : 142

Create a new user. The created user is published by this method.

public createUser(UserCreateStruct $userCreateStruct, array<string|int, mixed> $parentGroups) : User

Parameters

Name Type Default value Description
$userCreateStruct UserCreateStruct -

the data used for creating the user

$parentGroups array<string|int, mixed> -

the groups of type UserGroup which are assigned to the user after creation

Return values

User

Tags
Throws
UnauthorizedException

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

Throws
ContentFieldValidationException

if a field in the $userCreateStruct is not valid

Throws
ContentValidationException

if a required field is missing or set to an empty value

Throws
InvalidArgumentException

if a field value is not accepted by the field type if a user with provided login already exists

publiccreateUserGroup()

UserService.php : 45

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

public createUserGroup(UserGroupCreateStruct $userGroupCreateStruct, UserGroup $parentGroup) : UserGroup

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

Name Type Default value Description
$userGroupCreateStruct UserGroupCreateStruct -

a structure for setting all necessary data to create this user group

$parentGroup UserGroup - -

Return values

UserGroup

Tags
Throws
UnauthorizedException

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

Throws
InvalidArgumentException

if the input structure has invalid data

Throws
ContentFieldValidationException

if a field in the $userGroupCreateStruct is not valid

Throws
ContentValidationException

if a required field is missing or set to an empty value

publicdeleteUser()

UserService.php : 229

This method deletes a user.

public deleteUser(User $user) : array<string|int, int>

Parameters

Name Type Default value Description
$user User - -

Return values

array<string|int, int>

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

Tags
Throws
UnauthorizedException

if the authenticated user is not allowed to delete the user

publicdeleteUserGroup()

UserService.php : 98

Removes a user group.

public deleteUserGroup(UserGroup $userGroup) : array<string|int, int>

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

Parameters

Name Type Default value Description
$userGroup UserGroup - -

Return values

array<string|int, int>

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

Tags
Throws
UnauthorizedException

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

publicexpireUserToken()

UserService.php : 276

Expires user token with user hash.

public expireUserToken(string $hash) : void

Parameters

Name Type Default value Description
$hash string - -

publicgetPasswordInfo()

UserService.php : 408

Returns information about password for a given user.

public getPasswordInfo(User $user) : PasswordInfo

Parameters

Name Type Default value Description
$user User - -

Return values

PasswordInfo

publicisUser()

UserService.php : 339

Checks if Content is a user.

public isUser(Content $content) : bool

@since 7.4

Parameters

Name Type Default value Description
$content Content - -

Return values

bool

publicisUserGroup()

UserService.php : 350

Checks if Content is a user group.

public isUserGroup(Content $content) : bool

Parameters

Name Type Default value Description
$content Content - -

Return values

bool

publicloadSubUserGroups()

UserService.php : 85

Loads the sub groups of a user group.

public loadSubUserGroups(UserGroup $userGroup[, int $offset = 0 ][, int $limit = 25 ][, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, UserGroup>

Parameters

Name Type Default value Description
$userGroup UserGroup - -
$offset int 0

the start offset for paging

$limit int 25

the number of user groups returned

$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, UserGroup>

Tags
Throws
UnauthorizedException

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

publicloadUser()

UserService.php : 154

Loads a user.

public loadUser(mixed $userId[, array<string|int, string> $prioritizedLanguages = [] ]) : User

Parameters

Name Type Default value Description
$userId mixed - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

User

Tags
Throws
NotFoundException

if a user with the given id was not found

publicloadUserByEmail()

UserService.php : 191

Loads a user for the given email.

public loadUserByEmail(string $email[, array<string|int, string> $prioritizedLanguages = [] ]) : User

Parameters

Name Type Default value Description
$email string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

User

Tags
Throws
InvalidArgumentException

publicloadUserByLogin()

UserService.php : 169

Loads a user for the given login.

public loadUserByLogin(string $login[, array<string|int, string> $prioritizedLanguages = [] ]) : User

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

Parameters

Name Type Default value Description
$login string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

User

Tags
Throws
NotFoundException

if a user with the given credentials was not found

publicloadUserByToken()

UserService.php : 218

Loads a user with user hash key.

public loadUserByToken(string $hash[, array<string|int, string> $prioritizedLanguages = [] ]) : User

Parameters

Name Type Default value Description
$hash string - -
$prioritizedLanguages array<string|int, string> [] -

Return values

User

publicloadUserGroup()

UserService.php : 58

Loads a user group for the given id.

public loadUserGroup(int $id[, array<string|int, string> $prioritizedLanguages = [] ]) : UserGroup

Parameters

Name Type Default value Description
$id int - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

UserGroup

Tags
Throws
UnauthorizedException

if the authenticated user is not allowed to load a user group

Throws
NotFoundException

if the user group with the given id was not found

publicloadUserGroupByRemoteId()

UserService.php : 71

Loads a user group for the given remote id.

public loadUserGroupByRemoteId(string $remoteId[, array<string|int, string> $prioritizedLanguages = [] ]) : UserGroup

Parameters

Name Type Default value Description
$remoteId string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

UserGroup

Tags
Throws
UnauthorizedException

if the authenticated user is not allowed to load a user group

Throws
NotFoundException

if the user group with the given id was not found

publicloadUserGroupsOfUser()

UserService.php : 314

Loads the user groups the user belongs to.

public loadUserGroupsOfUser(User $user[, int $offset = 0 ][, int $limit = 25 ][, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, UserGroup>

Parameters

Name Type Default value Description
$user User - -
$offset int 0

the start offset for paging

$limit int 25

the number of user groups returned

$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, UserGroup>

Tags
Throws
UnauthorizedException

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

publicloadUsersByEmail()

UserService.php : 208

Loads a users for the given email.

public loadUsersByEmail(string $email[, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, User>

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

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

Parameters

Name Type Default value Description
$email string - -
$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, User>

Tags
Throws
InvalidArgumentException

publicloadUsersOfUserGroup()

UserService.php : 328

Loads the users of a user group.

public loadUsersOfUserGroup(UserGroup $userGroup[, int $offset = 0 ][, int $limit = 25 ][, array<string|int, string> $prioritizedLanguages = [] ]) : array<string|int, User>

Parameters

Name Type Default value Description
$userGroup UserGroup - -
$offset int 0

the start offset for paging

$limit int 25

the number of users returned

$prioritizedLanguages array<string|int, string> []

Used as prioritized language code on translated properties of returned object.

Return values

array<string|int, User>

Tags
Throws
UnauthorizedException

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

publicmoveUserGroup()

UserService.php : 108

Moves the user group to another parent.

public moveUserGroup(UserGroup $userGroup, UserGroup $newParent) : void

Parameters

Name Type Default value Description
$userGroup UserGroup - -
$newParent UserGroup - -
Tags
Throws
UnauthorizedException

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

publicnewUserCreateStruct()

UserService.php : 363

Instantiate a user create class.

public newUserCreateStruct(string $login, string $email, string $password, string $mainLanguageCode[, ContentType|null $contentType = null ]) : UserCreateStruct

Parameters

Name Type Default value Description
$login string -

the login of the new user

$email string -

the email of the new user

$password string -

the plain password of the new user

$mainLanguageCode string -

the main language for the underlying content object

$contentType ContentType|null null

content type for the underlying content object.

Return values

UserCreateStruct

publicnewUserGroupCreateStruct()

UserService.php : 373

Instantiate a user group create class.

public newUserGroupCreateStruct(string $mainLanguageCode[, ContentType|null $contentType = null ]) : UserGroupCreateStruct

Parameters

Name Type Default value Description
$mainLanguageCode string -

The main language for the underlying content object

$contentType ContentType|null null

5.x the content type for the underlying content object. In 4.x it is ignored and taken from the configuration

Return values

UserGroupCreateStruct

publicnewUserGroupUpdateStruct()

UserService.php : 387

Instantiate a new user group update struct.

public newUserGroupUpdateStruct() : UserGroupUpdateStruct

Return values

UserGroupUpdateStruct

publicnewUserUpdateStruct()

UserService.php : 380

Instantiate a new user update struct.

public newUserUpdateStruct() : UserUpdateStruct

Return values

UserUpdateStruct

publicunAssignUserFromUserGroup()

UserService.php : 300

Removes a user group from the user.

public unAssignUserFromUserGroup(User $user, UserGroup $userGroup) : void

Parameters

Name Type Default value Description
$user User - -
$userGroup UserGroup - -
Tags
Throws
UnauthorizedException

if the authenticated user is not allowed to remove the user group from the user

Throws
InvalidArgumentException

if the user is not in the given user group

Throws
BadStateException

If $userGroup is the last assigned user group

publicupdateUser()

UserService.php : 247

Updates a user.

public updateUser(User $user, UserUpdateStruct $userUpdateStruct) : 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

Name Type Default value Description
$user User - -
$userUpdateStruct UserUpdateStruct - -

Return values

User

Tags
Throws
ContentFieldValidationException

if a field in the $userUpdateStruct is not valid

Throws
ContentValidationException

if a required field is set empty

Throws
InvalidArgumentException

if a field value is not accepted by the field type

Throws
UnauthorizedException

if the authenticated user is not allowed to update the user

publicupdateUserGroup()

UserService.php : 126

Updates the group profile with fields and meta data.

public updateUserGroup(UserGroup $userGroup, UserGroupUpdateStruct $userGroupUpdateStruct) : UserGroup

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

Name Type Default value Description
$userGroup UserGroup - -
$userGroupUpdateStruct UserGroupUpdateStruct - -

Return values

UserGroup

Tags
Throws
UnauthorizedException

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

Throws
ContentFieldValidationException

if a field in the $userGroupUpdateStruct is not valid

Throws
ContentValidationException

if a required field is set empty

Throws
InvalidArgumentException

if a field value is not accepted by the field type

publicupdateUserPassword()

UserService.php : 259

Validates and updates just the user's password.

public updateUserPassword(User $user, string $newPassword) : User

Parameters

Name Type Default value Description
$user User - -
$newPassword string - -

Return values

User

Tags
Throws
ContentValidationException
Throws
ContentFieldValidationException

if new password does not pass validation

Throws
UnauthorizedException

if the authenticated user is not allowed to update the user

Throws
InvalidArgumentException
Throws
NotFoundException
Throws
Exception

publicupdateUserToken()

UserService.php : 269

Update the user token information specified by the user token struct.

public updateUserToken(User $user, UserTokenUpdateStruct $userTokenUpdateStruct) : User

Parameters

Name Type Default value Description
$user User - -
$userTokenUpdateStruct UserTokenUpdateStruct - -

Return values

User

publicvalidatePassword()

UserService.php : 399

Validates given password.

public validatePassword(string $password[, PasswordValidationContext|null $context = null ]) : array<string|int, ValidationError>

Parameters

Name Type Default value Description
$password string - -
$context PasswordValidationContext|null null -

Return values

array<string|int, ValidationError>

Tags
Throws
ContentValidationException