PHP Class Neos\Neos\Domain\Service\UserService

Afficher le fichier Open project: neos/neos-development-collection Class Usage Examples

Protected Properties

Свойство Type Description
$accountFactory Neos\Flow\Security\AccountFactory
$accountRepository Neos\Flow\Security\AccountRepository
$authenticationManager Neos\Flow\Security\Authentication\AuthenticationManagerInterface
$defaultAuthenticationProviderName string Might be configurable in the future, for now centralising this as a "constant"
$hashService Neos\Flow\Security\Cryptography\HashService
$now Neos\Flow\Utility\Now
$partyRepository Neos\Party\Domain\Repository\PartyRepository
$partyService Neos\Party\Domain\Service\PartyService
$policyService Neos\Flow\Security\Policy\PolicyService
$privilegeManager Neos\Flow\Security\Authorization\PrivilegeManagerInterface
$publishingService Neos\Neos\Service\PublishingService
$runtimeUserCache array
$securityContext Neos\Flow\Security\Context
$userRepository Neos\Neos\Domain\Repository\UserRepository
$workspaceRepository Neos\ContentRepository\Domain\Repository\WorkspaceRepository

Méthodes publiques

Méthode Description
activateUser ( User $user ) : void Reactivates the given user
addRoleToAccount ( Account $account, string $roleIdentifier ) : integer Adds the specified role to the given account and potentially carries out further actions which are needed to properly reflect these changes.
addRoleToUser ( User $user, string $roleIdentifier ) : integer Adds the specified role to all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
addUser ( string $username, string $password, User $user, array $roleIdentifiers = null, string $authenticationProviderName = null ) : User Adds a user whose User object has been created elsewhere
createUser ( string $username, string $password, string $firstName, string $lastName, array $roleIdentifiers = null, string $authenticationProviderName = null ) : User Creates a user based on the given information
currentUserCanManageWorkspace ( Workspace $workspace ) : boolean Checks if the current user may manage the given workspace according to one the roles of the user's accounts
currentUserCanPublishToWorkspace ( Workspace $workspace ) : boolean Checks if the current user may publish to the given workspace according to one the roles of the user's accounts
currentUserCanReadWorkspace ( Workspace $workspace ) : boolean Checks if the current user may read the given workspace according to one the roles of the user's accounts
currentUserCanTransferOwnershipOfWorkspace ( Workspace $workspace ) : boolean Checks if the current user may transfer ownership of the given workspace
deactivateUser ( User $user ) : void Deactivates the given user
deleteUser ( User $user ) : void Deletes the specified user and all remaining content in his personal workspaces
emitRolesAdded ( Account $account, array $roles ) : void Signals that new roles have been assigned to the given account
emitRolesRemoved ( Account $account, array $roles ) : void Signals that roles have been removed to the given account
emitUserActivated ( User $user ) : void Signals that the given user has been activated
emitUserCreated ( User $user ) : void Signals that a new user, including a new account has been created.
emitUserDeactivated ( User $user ) : void Signals that the given user has been activated
emitUserDeleted ( User $user ) : void Signals that the given user has been deleted.
emitUserUpdated ( User $user ) : void Signals that the given user data has been updated.
getCurrentUser ( ) : User Returns the currently logged in user, if any
getDefaultAuthenticationProviderName ( ) : string Returns the default authentication provider name
getUser ( string $username, string $authenticationProviderName = null ) : User Retrieves an existing user by the given username
getUsername ( User $user, string $authenticationProviderName = null ) : string Returns the username of the given user
getUsers ( ) : array Retrieves a list of all existing users
removeRoleFromAccount ( Account $account, string $roleIdentifier ) : integer Removes the specified role from the given account and potentially carries out further actions which are needed to properly reflect these changes.
removeRoleFromUser ( User $user, string $roleIdentifier ) : integer Removes the specified role from all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
setRolesForAccount ( Account $account, array $newRoleIdentifiers ) : void Overrides any assigned roles of the given account and potentially carries out further actions which are needed to properly reflect these changes.
setUserPassword ( User $user, string $password ) : void Sets a new password for the given user
updateUser ( User $user ) : void Updates the given user in the respective repository and potentially executes further actions depending on what has been changed.

Méthodes protégées

Méthode Description
createPersonalWorkspace ( User $user, Account $account ) Creates a personal workspace for the given user's account if it does not exist already.
deletePersonalWorkspace ( string $accountIdentifier ) : void Removes all personal workspaces of the given user's account if these workspaces exist. Also removes all possibly existing content of these workspaces.
getAllRoles ( User $user ) : array Returns an array with all roles of a user's accounts, including parent roles, the "Everybody" role and the "AuthenticatedUser" role, assuming that the user is logged in.
normalizeRoleIdentifier ( string $roleIdentifier ) : string Replaces a role identifier not containing a "." into fully qualified role identifier from the Neos.Neos namespace.
normalizeRoleIdentifiers ( array $roleIdentifiers ) : array Replaces role identifiers not containing a "." into fully qualified role identifiers from the Neos.Neos namespace.
removeOwnerFromUsersWorkspaces ( User $user ) : void Removes ownership of all workspaces currently owned by the given user

Method Details

activateUser() public méthode

Reactivates the given user
public activateUser ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user to deactivate
Résultat void

addRoleToAccount() public méthode

Adds the specified role to the given account and potentially carries out further actions which are needed to properly reflect these changes.
public addRoleToAccount ( Account $account, string $roleIdentifier ) : integer
$account Neos\Flow\Security\Account The account to add roles to
$roleIdentifier string A fully qualified role identifier, or a role identifier relative to the Neos.Neos namespace
Résultat integer How often this role has been added to the given account (effectively can be 1 or 0)

addRoleToUser() public méthode

Adds the specified role to all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
public addRoleToUser ( User $user, string $roleIdentifier ) : integer
$user Neos\Neos\Domain\Model\User The user to add roles to
$roleIdentifier string A fully qualified role identifier, or a role identifier relative to the Neos.Neos namespace
Résultat integer How often this role has been added to accounts owned by the user

addUser() public méthode

This method basically "creates" a user like createUser() would, except that it does not create the User object itself. If you need to create the User object elsewhere, for example in your ActionController, make sure to call this method for registering the new user instead of adding it to the PartyRepository manually. This method also creates a new user workspace for the given user if no such workspace exist.
public addUser ( string $username, string $password, User $user, array $roleIdentifiers = null, string $authenticationProviderName = null ) : User
$username string The username of the user to be created.
$password string Password of the user to be created
$user Neos\Neos\Domain\Model\User The pre-built user object to start with
$roleIdentifiers array A list of role identifiers to assign
$authenticationProviderName string Name of the authentication provider to use. Example: "Typo3BackendProvider"
Résultat Neos\Neos\Domain\Model\User The same user object

createPersonalWorkspace() protected méthode

Creates a personal workspace for the given user's account if it does not exist already.
protected createPersonalWorkspace ( User $user, Account $account )
$user Neos\Neos\Domain\Model\User The new user to create a workspace for
$account Neos\Flow\Security\Account The user's backend account

createUser() public méthode

The created user and account are automatically added to their respective repositories and thus be persisted.
public createUser ( string $username, string $password, string $firstName, string $lastName, array $roleIdentifiers = null, string $authenticationProviderName = null ) : User
$username string The username of the user to be created.
$password string Password of the user to be created
$firstName string First name of the user to be created
$lastName string Last name of the user to be created
$roleIdentifiers array A list of role identifiers to assign
$authenticationProviderName string Name of the authentication provider to use. Example: "Typo3BackendProvider"
Résultat Neos\Neos\Domain\Model\User The created user instance

currentUserCanManageWorkspace() public méthode

In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
public currentUserCanManageWorkspace ( Workspace $workspace ) : boolean
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace
Résultat boolean

currentUserCanPublishToWorkspace() public méthode

In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
public currentUserCanPublishToWorkspace ( Workspace $workspace ) : boolean
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace
Résultat boolean

currentUserCanReadWorkspace() public méthode

In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
public currentUserCanReadWorkspace ( Workspace $workspace ) : boolean
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace
Résultat boolean

currentUserCanTransferOwnershipOfWorkspace() public méthode

In future versions, this logic may be implemented in Neos in a more generic way (for example, by means of an ACL object), but for now, this method exists in order to at least centralize and encapsulate the required logic.
public currentUserCanTransferOwnershipOfWorkspace ( Workspace $workspace ) : boolean
$workspace Neos\ContentRepository\Domain\Model\Workspace The workspace
Résultat boolean

deactivateUser() public méthode

Deactivates the given user
public deactivateUser ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user to deactivate
Résultat void

deletePersonalWorkspace() protected méthode

Removes all personal workspaces of the given user's account if these workspaces exist. Also removes all possibly existing content of these workspaces.
protected deletePersonalWorkspace ( string $accountIdentifier ) : void
$accountIdentifier string Identifier of the user's account
Résultat void

deleteUser() public méthode

Deletes the specified user and all remaining content in his personal workspaces
public deleteUser ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user to delete
Résultat void

emitRolesAdded() public méthode

Signals that new roles have been assigned to the given account
public emitRolesAdded ( Account $account, array $roles ) : void
$account Neos\Flow\Security\Account The account
$roles array
Résultat void

emitRolesRemoved() public méthode

Signals that roles have been removed to the given account
public emitRolesRemoved ( Account $account, array $roles ) : void
$account Neos\Flow\Security\Account The account
$roles array
Résultat void

emitUserActivated() public méthode

Signals that the given user has been activated
public emitUserActivated ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user
Résultat void

emitUserCreated() public méthode

Signals that a new user, including a new account has been created.
public emitUserCreated ( User $user ) : void
$user Neos\Neos\Domain\Model\User The created user
Résultat void

emitUserDeactivated() public méthode

Signals that the given user has been activated
public emitUserDeactivated ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user
Résultat void

emitUserDeleted() public méthode

Signals that the given user has been deleted.
public emitUserDeleted ( User $user ) : void
$user Neos\Neos\Domain\Model\User The created user
Résultat void

emitUserUpdated() public méthode

Signals that the given user data has been updated.
public emitUserUpdated ( User $user ) : void
$user Neos\Neos\Domain\Model\User The created user
Résultat void

getAllRoles() protected méthode

Returns an array with all roles of a user's accounts, including parent roles, the "Everybody" role and the "AuthenticatedUser" role, assuming that the user is logged in.
protected getAllRoles ( User $user ) : array
$user Neos\Neos\Domain\Model\User The user
Résultat array

getCurrentUser() public méthode

Returns the currently logged in user, if any
public getCurrentUser ( ) : User
Résultat Neos\Neos\Domain\Model\User The currently logged in user, or null

getDefaultAuthenticationProviderName() public méthode

Returns the default authentication provider name

getUser() public méthode

Retrieves an existing user by the given username
public getUser ( string $username, string $authenticationProviderName = null ) : User
$username string The username
$authenticationProviderName string Name of the authentication provider to use. Example: "Typo3BackendProvider"
Résultat Neos\Neos\Domain\Model\User The user, or null if the user does not exist

getUsername() public méthode

Technically, this method will look for the user's backend account (or, if authenticationProviderName is specified, for the account matching the given authentication provider) and return the account's identifier.
public getUsername ( User $user, string $authenticationProviderName = null ) : string
$user Neos\Neos\Domain\Model\User
$authenticationProviderName string
Résultat string The username or null if the given user does not have a backend account

getUsers() public méthode

Retrieves a list of all existing users
public getUsers ( ) : array
Résultat array

normalizeRoleIdentifier() protected méthode

Replaces a role identifier not containing a "." into fully qualified role identifier from the Neos.Neos namespace.
protected normalizeRoleIdentifier ( string $roleIdentifier ) : string
$roleIdentifier string
Résultat string

normalizeRoleIdentifiers() protected méthode

Replaces role identifiers not containing a "." into fully qualified role identifiers from the Neos.Neos namespace.
protected normalizeRoleIdentifiers ( array $roleIdentifiers ) : array
$roleIdentifiers array
Résultat array

removeOwnerFromUsersWorkspaces() protected méthode

Removes ownership of all workspaces currently owned by the given user
protected removeOwnerFromUsersWorkspaces ( User $user ) : void
$user Neos\Neos\Domain\Model\User The user currently owning workspaces
Résultat void

removeRoleFromAccount() public méthode

Removes the specified role from the given account and potentially carries out further actions which are needed to properly reflect these changes.
public removeRoleFromAccount ( Account $account, string $roleIdentifier ) : integer
$account Neos\Flow\Security\Account The account to remove roles from
$roleIdentifier string A fully qualified role identifier, or a role identifier relative to the Neos.Neos namespace
Résultat integer How often this role has been removed from the given account (effectively can be 1 or 0)

removeRoleFromUser() public méthode

Removes the specified role from all accounts of the given user and potentially carries out further actions which are needed to properly reflect these changes.
public removeRoleFromUser ( User $user, string $roleIdentifier ) : integer
$user Neos\Neos\Domain\Model\User The user to remove roles from
$roleIdentifier string A fully qualified role identifier, or a role identifier relative to the Neos.Neos namespace
Résultat integer How often this role has been removed from accounts owned by the user

setRolesForAccount() public méthode

Overrides any assigned roles of the given account and potentially carries out further actions which are needed to properly reflect these changes.
public setRolesForAccount ( Account $account, array $newRoleIdentifiers ) : void
$account Neos\Flow\Security\Account The account to assign the roles to
$newRoleIdentifiers array A list of fully qualified role identifiers, or role identifiers relative to the Neos.Neos namespace
Résultat void

setUserPassword() public méthode

This method will iterate over all accounts owned by the given user and, if the account uses a UsernamePasswordToken, sets a new password accordingly.
public setUserPassword ( User $user, string $password ) : void
$user Neos\Neos\Domain\Model\User The user to set the password for
$password string A new password
Résultat void

updateUser() public méthode

Note: changes to the user's account will not be committed for persistence. Please use addRoleToAccount(), removeRoleFromAccount(), setRolesForAccount() and setUserPassword() for changing account properties.
public updateUser ( User $user ) : void
$user Neos\Neos\Domain\Model\User The modified user
Résultat void

Property Details

$accountFactory protected_oe property

protected AccountFactory,Neos\Flow\Security $accountFactory
Résultat Neos\Flow\Security\AccountFactory

$accountRepository protected_oe property

protected AccountRepository,Neos\Flow\Security $accountRepository
Résultat Neos\Flow\Security\AccountRepository

$authenticationManager protected_oe property

protected AuthenticationManagerInterface,Neos\Flow\Security\Authentication $authenticationManager
Résultat Neos\Flow\Security\Authentication\AuthenticationManagerInterface

$defaultAuthenticationProviderName protected_oe property

Might be configurable in the future, for now centralising this as a "constant"
protected string $defaultAuthenticationProviderName
Résultat string

$hashService protected_oe property

protected HashService,Neos\Flow\Security\Cryptography $hashService
Résultat Neos\Flow\Security\Cryptography\HashService

$now protected_oe property

protected Now,Neos\Flow\Utility $now
Résultat Neos\Flow\Utility\Now

$partyRepository protected_oe property

protected PartyRepository,Neos\Party\Domain\Repository $partyRepository
Résultat Neos\Party\Domain\Repository\PartyRepository

$partyService protected_oe property

protected PartyService,Neos\Party\Domain\Service $partyService
Résultat Neos\Party\Domain\Service\PartyService

$policyService protected_oe property

protected PolicyService,Neos\Flow\Security\Policy $policyService
Résultat Neos\Flow\Security\Policy\PolicyService

$privilegeManager protected_oe property

protected PrivilegeManagerInterface,Neos\Flow\Security\Authorization $privilegeManager
Résultat Neos\Flow\Security\Authorization\PrivilegeManagerInterface

$publishingService protected_oe property

protected PublishingService,Neos\Neos\Service $publishingService
Résultat Neos\Neos\Service\PublishingService

$runtimeUserCache protected_oe property

protected array $runtimeUserCache
Résultat array

$securityContext protected_oe property

protected Context,Neos\Flow\Security $securityContext
Résultat Neos\Flow\Security\Context

$userRepository protected_oe property

protected UserRepository,Neos\Neos\Domain\Repository $userRepository
Résultat Neos\Neos\Domain\Repository\UserRepository

$workspaceRepository protected_oe property

protected WorkspaceRepository,Neos\ContentRepository\Domain\Repository $workspaceRepository
Résultat Neos\ContentRepository\Domain\Repository\WorkspaceRepository