abstract class AbstractEventVariables in Hook Event Dispatcher 8
Class AbstractEventVariables.
Plugin annotation
@SuppressWarnings(PHPMD . NumberOfChildren);
Hierarchy
- class \Drupal\hook_event_dispatcher\Event\Preprocess\Variables\AbstractEventVariables
Expanded class hierarchy of AbstractEventVariables
6 files declare their use of AbstractEventVariables
- AbstractPreprocessEvent.php in src/
Event/ Preprocess/ AbstractPreprocessEvent.php - EntityEventTest.php in tests/
src/ Unit/ Preprocess/ EntityEventTest.php - ExampleEventVariables.php in src/
Example/ preprocess_example_module/ src/ Event/ Variables/ ExampleEventVariables.php - FakeEventVariables.php in tests/
src/ Unit/ Preprocess/ Helpers/ FakeEventVariables.php - OtherEventTest.php in tests/
src/ Unit/ Preprocess/ OtherEventTest.php
File
- src/
Event/ Preprocess/ Variables/ AbstractEventVariables.php, line 10
Namespace
Drupal\hook_event_dispatcher\Event\Preprocess\VariablesView source
abstract class AbstractEventVariables {
/**
* Variables.
*
* @var array
*/
protected $variables;
/**
* Event Variables constructor.
*
* @param array $variables
* Event variables.
*/
public function __construct(array &$variables) {
$this->variables =& $variables;
}
/**
* Get a variable with a given name, return default if it does not exist.
*
* @param string $name
* Variable name.
* @param mixed|null $default
* Default value.
*
* @return mixed
* Value for variable BY VALUE.
*/
public function get($name, $default = NULL) {
return \array_key_exists($name, $this->variables) ? $this->variables[$name] : $default;
}
/**
* Set a variable to a given value.
*
* @param string $name
* Variable name.
* @param mixed $value
* Variable value.
*
* @return $this
* Event variables.
*/
public function set($name, $value = NULL) {
$this->variables[$name] = $value;
return $this;
}
/**
* Remove a given variable.
*
* @param string $name
* Variable name.
*
* @return $this
* Event variables.
*/
public function remove($name) {
unset($this->variables[$name]);
return $this;
}
/**
* Get a variable with a given name by reference.
*
* @param string $name
* Variable name.
*
* @return mixed
* Reference for the variable.
*/
public function &getByReference($name) {
return $this->variables[$name];
}
}
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. |