Documentation

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
author

Fabien Potencier fabien@symfony.com

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

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

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
UserInterface

supportsClass()

Whether this provider supports the given user class.

public supportsClass(string $class) : bool
Parameters
$class : string
Return values
bool

getUser()

Returns the user by given username.

private getUser(string $username) : mixed
Parameters
$username : string
Tags
throws
UserNotFoundException

if user whose given username does not exist


        
On this page

Search results