requestStack = $requestStack; $this->session = $session; } public function loadUserByIdentifier(string $identifier, ?User $user): ?UserInterface { if ($user->getUserIdentifier() === $identifier) { return $user; } return null; } public function loadUserByUsername(string $username): ?UserInterface { return $this->loadUserByIdentifier($username, null); } public function refreshUser(UserInterface $user) { if (!$user instanceof User) { throw new UnsupportedUserException(sprintf('Invalid user class "%s".', get_class($user))); } return $this->loadUserByIdentifier($user->getUserIdentifier(), $user); } public function supportsClass(string $class) { return User::class === $class || is_subclass_of($class, User::class); } }