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
Interfaces, Classes, Traits and Enums
- UserProviderInterface
- Represents a class that loads UserInterface objects from some source for the authentication system.
Table of Contents
- $users : mixed
- __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.
- loadUserByUsername() : UserInterface
- Loads the user for the given username.
- refreshUser() : UserInterface
- Refreshes the user.
- supportsClass() : bool
- Whether this provider supports the given user class.
- getUser() : User
- Returns the user by given username.
Properties
$users
private
mixed
$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|int, mixed> $users = [] ]) : mixed
Parameters
- $users : array<string|int, mixed> = []
-
An array of users
Return values
mixed —createUser()
Adds a new User to the provider.
public
createUser(UserInterface $user) : mixed
Parameters
- $user : UserInterface
Tags
Return values
mixed —loadUserByUsername()
Loads the user for the given username.
public
loadUserByUsername(mixed $username) : UserInterface
Parameters
- $username : mixed
-
The username
Return values
UserInterface —refreshUser()
Refreshes the user.
public
refreshUser(UserInterface $user) : UserInterface
Parameters
- $user : UserInterface
Return values
UserInterface —supportsClass()
Whether this provider supports the given user class.
public
supportsClass(mixed $class) : bool
Parameters
- $class : mixed
Return values
bool —getUser()
Returns the user by given username.
private
getUser(string $username) : User
Parameters
- $username : string