You are here

class BlockEventVariables in Hook Event Dispatcher 8

Class BlockEventVariables.

Hierarchy

Expanded class hierarchy of BlockEventVariables

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

File

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

Namespace

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

  /**
   * Get the block.
   *
   * @return \Drupal\block\Entity\Block
   *   The block.
   */
  public function getBlock() {
    return $this->variables['block'];
  }

  /**
   * Get the block identifier.
   *
   * @return string
   *   Identifier for the block.
   */
  public function getId() {
    return $this->variables['elements']['#id'];
  }

  /**
   * Get the content for a given child.
   *
   * @param string $childName
   *   Name of the child.
   *
   * @return array
   *   Content of the child or [].
   */
  public function getContentChild($childName) {
    if (isset($this->variables['content'][$childName])) {
      return $this->variables['content'][$childName];
    }
    return [];
  }

}

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.
BlockEventVariables::getBlock public function Get the block.
BlockEventVariables::getContentChild public function Get the content for a given child.
BlockEventVariables::getId public function Get the block identifier.