You are here

class UsernameEventVariables in Hook Event Dispatcher 8

Class UsernameEventVariables.

Hierarchy

Expanded class hierarchy of UsernameEventVariables

2 files declare their use of UsernameEventVariables
OtherEventVariablesTest.php in tests/src/Unit/Preprocess/OtherEventVariablesTest.php
UsernamePreprocessEventFactory.php in src/Event/Preprocess/Factory/UsernamePreprocessEventFactory.php

File

src/Event/Preprocess/Variables/UsernameEventVariables.php, line 8

Namespace

Drupal\hook_event_dispatcher\Event\Preprocess\Variables
View source
class UsernameEventVariables extends AbstractEventVariables {

  /**
   * Whether the user is anonymous or not.
   *
   * @return bool
   *   Is it?
   */
  public function userIsAnonymous() {
    return $this
      ->getAccount()
      ->isAnonymous();
  }

  /**
   * Get the user account.
   *
   * @return \Drupal\user\Entity\User
   *   The user account.
   */
  public function getAccount() {
    return $this->variables['account'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractEventVariables::$variables protected property Variables.
AbstractEventVariables::get public function Get a variable with a given name, return default if it does not exist. 1
AbstractEventVariables::getByReference public function Get a variable with a given name by reference. 1
AbstractEventVariables::remove public function Remove a given variable. 1
AbstractEventVariables::set public function Set a variable to a given value. 1
AbstractEventVariables::__construct public function Event Variables constructor.
UsernameEventVariables::getAccount public function Get the user account.
UsernameEventVariables::userIsAnonymous public function Whether the user is anonymous or not.