8000 improved the UserRepository::refreshUser() method as in EntityUserPro… · web-dev/symfony-docs@b85c98b · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit b85c98b

Browse files
Hugo Hamonweaverryan
authored andcommitted
improved the UserRepository::refreshUser() method as in EntityUserProvider class.
1 parent 09d0924 commit b85c98b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

cookbook/security/entity_provider.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,12 @@ The code below shows the implementation of the
344344
345345
public function refreshUser(UserInterface $user)
346346
{
347-
$username = $user->getUsername();
348-
349-
try {
350-
$user = $this->loadUserByUsername($username);
351-
} catch (UsernameNotFoundException $e) {
352-
throw new UnsupportedUserException(sprintf('Unable to refresh active admin AcmeUserBundle:User object identified by "%s".', $username), null, 0, $e);
347+
$class = get_class($user);
348+
if (!$this->supportsClass($class)) {
349+
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $class));
353350
}
354351
355-
return $user;
352+
return $this->loadUserByUsername($user->getUsername());
356353
}
357354
358355
public function supportsClass($class)

0 commit comments

Comments
 (0)
0