Skip to content

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).

final class CallableUserProvider implements UserProviderInterface

ImplementsUserProviderInterface
Since1.0.0
SourceProvider/CallableUserProvider.php

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.

ParameterTypeDescription
$byIdentifiercallable(string): ?UserIdentityResolves an identifier (e.g. email/username) to an identity.
$byToken`callable(TokenClaims): ?UserIdentity““null`

Returns mixed

MethodDescription
loadByIdentifier(string $identifier): ?UserIdentity
loadByToken(TokenClaims $claims): ?UserIdentity

public function loadByIdentifier(string $identifier): ?UserIdentity

E.g. an email or username.

ParameterTypeDescription
$identifierstringE.g. an email or username.

Returns ?UserIdentity — Whatever the $byIdentifier callable returns.

public function loadByToken(TokenClaims $claims): ?UserIdentity

The validated token claims.

ParameterTypeDescription
$claimsTokenClaimsThe validated token claims.

Returns ?UserIdentity — Whatever the $byToken callable returns, or null if none was supplied.