eZ\Publish\Core\Repository\Repository::setCurrentUser PHP Method

setCurrentUser() public method

Deprecation: since 6.6, to be removed. Use PermissionResolver::setCurrentUserReference() instead. Sets the current user to the given $user.
public setCurrentUser ( eZ\Publish\API\Repository\Values\User\UserReference $user )
$user eZ\Publish\API\Repository\Values\User\UserReference
    public function setCurrentUser(APIUserReference $user)
    {
        $id = $user->getUserId();
        if (!$id) {
            throw new InvalidArgumentValue('$user->getUserId()', $id);
        }
        if ($user instanceof User) {
            $this->currentUser = $user;
            $this->currentUserRef = new UserReference($id);
        } else {
            $this->currentUser = null;
            $this->currentUserRef = $user;
        }
        return $this->getPermissionResolver()->setCurrentUserReference($this->currentUserRef);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Setup test
  */
 protected function setUp()
 {
     parent::setUp();
     $this->repository = static::getRepository();
     $this->repository->setCurrentUser($this->getStubbedUser(14));
 }