You are here

public function AccountProxy::setAccount in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Session/AccountProxy.php \Drupal\Core\Session\AccountProxy::setAccount()
  2. 9 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);
}