SwitchUserToken
extends UsernamePasswordToken
in package
Token representing a user who temporarily impersonates another one.
Tags
Table of Contents
- $attributes : mixed
- $authenticated : mixed
- $credentials : mixed
- $originalToken : mixed
- $providerKey : mixed
- $roleNames : mixed
- $roles : mixed
- $user : mixed
- __construct() : mixed
- __serialize() : array<string|int, mixed>
- Returns all the necessary state of the object for serialization purposes.
- __toString() : string
- Returns a string representation of the Token.
- __unserialize() : void
- Restores the object state from an array given by __serialize().
- eraseCredentials() : mixed
- Removes sensitive information from the token.
- getAttribute() : mixed
- Returns an attribute value.
- getAttributes() : array<string|int, mixed>
- Returns the token attributes.
- getCredentials() : mixed
- {@inheritdoc}
- getOriginalToken() : TokenInterface
- getProviderKey() : string
- Returns the provider key.
- getRoleNames() : array<string|int, mixed>
- getRoles() : array<string|int, Role>
- Returns the user roles.
- getUser() : string|Stringable|UserInterface
- Returns a user representation.
- getUsername() : string
- Returns the username.
- hasAttribute() : bool
- Returns true if the attribute exists.
- isAuthenticated() : bool
- Returns whether the user is authenticated or not.
- setAttribute() : mixed
- Sets an attribute.
- setAttributes() : mixed
- Sets the token attributes.
- setAuthenticated() : mixed
- Sets the authenticated flag.
- setUser() : mixed
- Sets the user in the token.
- hasUserChanged() : bool
Properties
$attributes
private
mixed
$attributes
= []
$authenticated
private
mixed
$authenticated
= false
$credentials
private
mixed
$credentials
$originalToken
private
mixed
$originalToken
$providerKey
private
mixed
$providerKey
$roleNames
private
mixed
$roleNames
= []
$roles
private
mixed
$roles
= []
$user
private
mixed
$user
Methods
__construct()
public
__construct(string|object $user, mixed $credentials, string $providerKey, array<string|int, string> $roles, TokenInterface $originalToken) : mixed
Parameters
- $user : string|object
-
The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
- $credentials : mixed
-
This usually is the password of the user
- $providerKey : string
-
The provider key
- $roles : array<string|int, string>
-
An array of roles
- $originalToken : TokenInterface
Tags
Return values
mixed —__serialize()
Returns all the necessary state of the object for serialization purposes.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__toString()
Returns a string representation of the Token.
public
__toString() : string
Return values
string —__unserialize()
Restores the object state from an array given by __serialize().
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
Return values
void —eraseCredentials()
Removes sensitive information from the token.
public
eraseCredentials() : mixed
Return values
mixed —getAttribute()
Returns an attribute value.
public
getAttribute(string $name) : mixed
Parameters
- $name : string
-
The attribute name
Tags
Return values
mixed —The attribute value
getAttributes()
Returns the token attributes.
public
getAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed> —The token attributes
getCredentials()
{@inheritdoc}
public
getCredentials() : mixed
Return values
mixed —getOriginalToken()
public
getOriginalToken() : TokenInterface
Return values
TokenInterface —getProviderKey()
Returns the provider key.
public
getProviderKey() : string
Return values
string —The provider key
getRoleNames()
public
getRoleNames() : array<string|int, mixed>
Return values
array<string|int, mixed> —getRoles()
Returns the user roles.
public
getRoles() : array<string|int, Role>
Return values
array<string|int, Role> —An array of Role instances
getUser()
Returns a user representation.
public
getUser() : string|Stringable|UserInterface
Return values
string|Stringable|UserInterface —getUsername()
Returns the username.
public
getUsername() : string
Return values
string —hasAttribute()
Returns true if the attribute exists.
public
hasAttribute(string $name) : bool
Parameters
- $name : string
-
The attribute name
Return values
bool —true if the attribute exists, false otherwise
isAuthenticated()
Returns whether the user is authenticated or not.
public
isAuthenticated() : bool
Return values
bool —true if the token has been authenticated, false otherwise
setAttribute()
Sets an attribute.
public
setAttribute(string $name, mixed $value) : mixed
Parameters
- $name : string
-
The attribute name
- $value : mixed
-
The attribute value
Return values
mixed —setAttributes()
Sets the token attributes.
public
setAttributes(array<string|int, mixed> $attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
-
The token attributes
Return values
mixed —setAuthenticated()
Sets the authenticated flag.
public
setAuthenticated(mixed $authenticated) : mixed
Parameters
- $authenticated : mixed
Return values
mixed —setUser()
Sets the user in the token.
public
setUser(mixed $user) : mixed
Parameters
- $user : mixed
Return values
mixed —hasUserChanged()
private
hasUserChanged(UserInterface $user) : bool
Parameters
- $user : UserInterface