CallableUserProvider
Delegates identity/claim resolution to app-supplied callables, for lookups that don’t fit InMemoryUserProvider’s static list or PdoUserProvider’s single-table convention (e.g.
joining across services, calling a legacy API).
Synopsis
Section titled “Synopsis”final class CallableUserProvider implements UserProviderInterface
| Implements | UserProviderInterface |
| Since | 1.0.0 |
| Source | Provider/CallableUserProvider.php |
Constructor
Section titled “Constructor”__construct()
Section titled “__construct()”public function __construct(callable(string): ?UserIdentity $byIdentifier, callable(TokenClaims): ?UserIdentity|null $byToken = null): mixed
Resolves validated token claims to an identity, if token-based auth is used.
| Parameter | Type | Description |
|---|---|---|
$byIdentifier | callable(string): ?UserIdentity | Resolves an identifier (e.g. email/username) to an identity. |
$byToken | `callable(TokenClaims): ?UserIdentity“ | “null` |
Returns mixed
Methods
Section titled “Methods”| Method | Description |
|---|---|
loadByIdentifier(string $identifier): ?UserIdentity | |
loadByToken(TokenClaims $claims): ?UserIdentity |
loadByIdentifier()
Section titled “loadByIdentifier()”public function loadByIdentifier(string $identifier): ?UserIdentity
E.g. an email or username.
| Parameter | Type | Description |
|---|---|---|
$identifier | string | E.g. an email or username. |
Returns ?UserIdentity — Whatever the $byIdentifier callable returns.
loadByToken()
Section titled “loadByToken()”public function loadByToken(TokenClaims $claims): ?UserIdentity
The validated token claims.
| Parameter | Type | Description |
|---|---|---|
$claims | TokenClaims | The validated token claims. |
Returns ?UserIdentity — Whatever the $byToken callable returns, or null if none was supplied.