function AccountProxy::setAccount

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Session/AccountProxy.php \Drupal\Core\Session\AccountProxy::setAccount()
  2. 10 core/lib/Drupal/Core/Session/AccountProxy.php \Drupal\Core\Session\AccountProxy::setAccount()
  3. 11.x core/lib/Drupal/Core/Session/AccountProxy.php \Drupal\Core\Session\AccountProxy::setAccount()

Overrides AccountProxyInterface::setAccount

1 call to AccountProxy::setAccount()
AccountProxy::getAccount in core/lib/Drupal/Core/Session/AccountProxy.php
Gets the currently wrapped account.

File

core/lib/Drupal/Core/Session/AccountProxy.php, line 57

Class

AccountProxy
A proxied implementation of AccountInterface.

Namespace

Drupal\Core\Session

Code

public function setAccount(AccountInterface $account) {
    // If the passed account is already proxied, use the actual account instead
    // to prevent loops.
    if ($account instanceof static) {
        $account = $account->getAccount();
    }
    $this->account = $account;
    $this->id = $account->id();
    $this->eventDispatcher
        ->dispatch(new AccountSetEvent($account), AccountEvents::SET_USER);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.