public function refreshUser(UserInterface $user) { if (!$user instanceof User) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); } if (!$this->supportsClass(get_class($user))) { throw new UnsupportedUserException(sprintf('Expected an instance of %s, but got "%s".', $this->userManager->getUserCLass(), get_class($user))); } $refreshedUser = $this->userManager->findUserById($user->getId()); if (null === $refreshedUser) { throw new UsernameNotFoundException(sprintf('User with ID "%d" could not be refreshed.', $user->getId())); } return $refreshedUser; }