AccountSetEvent example

/** * {@inheritdoc} */
  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);
  }

  /** * {@inheritdoc} */
  public function getAccount() {
    if (!isset($this->account)) {
      if ($this->id) {
        // After the container is rebuilt, DrupalKernel sets the initial         // account to the id of the logged in user. This is necessary in order         // to refresh the user account reference here.
Home | Imprint | This part of the site doesn't use cookies.