InMemoryUserProvider
in package
implements
UserProviderInterface
InMemoryUserProvider is a simple non persistent user provider.
Useful for testing, demonstration, prototyping, and for simple needs (a backend with a unique admin for instance)
Tags
Table of Contents
Interfaces
- UserProviderInterface
- Represents a class that loads UserInterface objects from some source for the authentication system.
Properties
- $users : array<string, UserInterface>
Methods
- __construct() : mixed
- The user array is a hash where the keys are usernames and the values are an array of attributes: 'password', 'enabled', and 'roles'.
- createUser() : mixed
- Adds a new User to the provider.
- loadUserByIdentifier() : UserInterface
- Loads the user for the given user identifier (e.g. username or email).
- refreshUser() : UserInterface
- Refreshes the user.
- supportsClass() : bool
- Whether this provider supports the given user class.
- getUser() : mixed
- Returns the user by given username.
Properties
$users
private
array<string, UserInterface>
$users
= []
Methods
__construct()
The user array is a hash where the keys are usernames and the values are an array of attributes: 'password', 'enabled', and 'roles'.
public
__construct([array<string, array{password?: string, enabled?: bool, roles?: list}> $users = [] ]) : mixed
Parameters
-
$users
: array<string, array{password?: string, enabled?: bool, roles?: list
}> = [] -
An array of users
createUser()
Adds a new User to the provider.
public
createUser(UserInterface $user) : mixed
Parameters
- $user : UserInterface
Tags
loadUserByIdentifier()
Loads the user for the given user identifier (e.g. username or email).
public
loadUserByIdentifier(string $identifier) : UserInterface
This method must throw UserNotFoundException if the user is not found.
Parameters
- $identifier : string
Return values
UserInterfacerefreshUser()
Refreshes the user.
public
refreshUser(UserInterface $user) : UserInterface
Parameters
- $user : UserInterface
Return values
UserInterfacesupportsClass()
Whether this provider supports the given user class.
public
supportsClass(string $class) : bool
Parameters
- $class : string
Return values
boolgetUser()
Returns the user by given username.
private
getUser(string $username) : mixed
Parameters
- $username : string