*/ final class KimaiUserProvider implements UserProviderInterface, PasswordUpgraderInterface { private ?ChainUserProvider $provider = null; /** * @param iterable|UserProviderInterface[] $providers */ public function __construct(private iterable $providers, private SystemConfiguration $configuration) { } private function getInternalProvider(): ChainUserProvider { if ($this->provider === null) { $activated = []; foreach ($this->providers as $provider) { if ($provider instanceof LdapUserProvider) { if (!class_exists('Laminas\Ldap\Ldap')) { continue; } if (!$this->configuration->isLdapActive()) { continue; } } $activated[] = $provider; } $this->provider = new ChainUserProvider(new \ArrayIterator($activated)); } return $this->provider; } public function getProviders(): array { return $this->getInternalProvider()->getProviders(); } public function loadUserByIdentifier(string $identifier): UserInterface { return $this->getInternalProvider()->loadUserByIdentifier($identifier); } public function refreshUser(UserInterface $user): UserInterface { return $this->getInternalProvider()->refreshUser($user); } public function supportsClass(string $class): bool { return $this->getInternalProvider()->supportsClass($class); } public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void { $this->getInternalProvider()->upgradePassword($user, $newHashedPassword); } }