function AccountProxy::setAccount

Same name and namespace in other branches
  1. 11.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. 8.9.x core/lib/Drupal/Core/Session/AccountProxy.php \Drupal\Core\Session\AccountProxy::setAccount()

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.