eZ\Publish\Core\MVC\Symfony\Security\User\Provider::refreshUser PHP Method

refreshUser() public method

It is up to the implementation to decide if the user data should be totally reloaded (e.g. from the database), or if the UserInterface object can just be merged into some internal array of users / identity map.
public refreshUser ( Symfony\Component\Security\Core\User\UserInterface $user ) : Symfony\Component\Security\Core\User\UserInterface
$user Symfony\Component\Security\Core\User\UserInterface
return Symfony\Component\Security\Core\User\UserInterface
    public function refreshUser(CoreUserInterface $user)
    {
        if (!$user instanceof UserInterface) {
            throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user)));
        }
        try {
            $refreshedAPIUser = $this->repository->getUserService()->loadUser($user->getAPIUser()->id);
            $user->setAPIUser($refreshedAPIUser);
            $this->repository->setCurrentUser($refreshedAPIUser);
            return $user;
        } catch (NotFoundException $e) {
            throw new UsernameNotFoundException($e->getMessage(), 0, $e);
        }
    }

Usage Example

Beispiel #1
0
 public function testRefreshUser()
 {
     $apiUser = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\User\\User');
     $user = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Security\\UserInterface');
     $user->expects($this->once())->method('getAPIUser')->will($this->returnValue($apiUser));
     $this->repository->expects($this->once())->method('setCurrentUser')->with($apiUser);
     $this->assertSame($user, $this->userProvider->refreshUser($user));
 }
All Usage Examples Of eZ\Publish\Core\MVC\Symfony\Security\User\Provider::refreshUser