class BlockEventVariables in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/preprocess_event_dispatcher/src/Variables/BlockEventVariables.php \Drupal\preprocess_event_dispatcher\Variables\BlockEventVariables
Class BlockEventVariables.
Hierarchy
- class \Drupal\preprocess_event_dispatcher\Variables\AbstractEventVariables
- class \Drupal\preprocess_event_dispatcher\Variables\BlockEventVariables
Expanded class hierarchy of BlockEventVariables
2 files declare their use of BlockEventVariables
- BlockPreprocessEventFactory.php in modules/
preprocess_event_dispatcher/ src/ Factory/ BlockPreprocessEventFactory.php - OtherEventVariablesTest.php in modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ OtherEventVariablesTest.php
File
- modules/
preprocess_event_dispatcher/ src/ Variables/ BlockEventVariables.php, line 11
Namespace
Drupal\preprocess_event_dispatcher\VariablesView source
class BlockEventVariables extends AbstractEventVariables {
/**
* Get the block.
*
* @return \Drupal\block\BlockInterface
* The block.
*/
public function getBlock() : BlockInterface {
return $this->variables['block'];
}
/**
* Get the block identifier.
*
* @return string
* Identifier for the block.
*/
public function getId() : string {
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(string $childName) : array {
return $this->variables['content'][$childName] ?? [];
}
/**
* Get the block content.
*
* @return null|\Drupal\block_content\BlockContentInterface
* Block Content Entity or NULL.
*/
public function getBlockContent() : ?BlockContentInterface {
return $this->variables['content']['#block_content'] ?? NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AbstractEventVariables:: |
protected | property | Variables. | |
AbstractEventVariables:: |
public | function | Get a variable with a given name, return default if it does not exist. | 1 |
AbstractEventVariables:: |
public | function | Get a variable with a given name by reference. | 1 |
AbstractEventVariables:: |
public | function | Remove a given variable. | 1 |
AbstractEventVariables:: |
public | function | Set a variable to a given value. | 1 |
AbstractEventVariables:: |
public | function | Event Variables constructor. | |
BlockEventVariables:: |
public | function | Get the block. | |
BlockEventVariables:: |
public | function | Get the block content. | |
BlockEventVariables:: |
public | function | Get the content for a given child. | |
BlockEventVariables:: |
public | function | Get the block identifier. |