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