function AccountProxy::setAccount

Same name and namespace in other branches
  1. 9 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 71

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(AccountEvents::SET_USER, new AccountSetEvent($account));
}

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