abstract class AbstractEventVariables in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/preprocess_event_dispatcher/src/Variables/AbstractEventVariables.php \Drupal\preprocess_event_dispatcher\Variables\AbstractEventVariables
Class AbstractEventVariables.
Plugin annotation
@SuppressWarnings(PHPMD . NumberOfChildren);
Hierarchy
- class \Drupal\preprocess_event_dispatcher\Variables\AbstractEventVariables
Expanded class hierarchy of AbstractEventVariables
6 files declare their use of AbstractEventVariables
- AbstractPreprocessEvent.php in modules/
preprocess_event_dispatcher/ src/ Event/ AbstractPreprocessEvent.php - ExampleEventVariables.php in examples/
preprocess_example_module/ src/ Variables/ ExampleEventVariables.php - FakeEventVariables.php in modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ Helpers/ FakeEventVariables.php - OtherEventVariablesTest.php in modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ OtherEventVariablesTest.php - PreprocessEntityEventInterface.php in modules/
preprocess_event_dispatcher/ src/ Event/ PreprocessEntityEventInterface.php
File
- modules/
preprocess_event_dispatcher/ src/ Variables/ AbstractEventVariables.php, line 12
Namespace
Drupal\preprocess_event_dispatcher\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(string $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.
*/
public function set(string $name, $value = NULL) : void {
$this->variables[$name] = $value;
}
/**
* Remove a given variable.
*
* @param string $name
* Variable name.
*/
public function remove(string $name) : void {
unset($this->variables[$name]);
}
/**
* Get a variable with a given name by reference.
*
* @param string $name
* Variable name.
*
* @return mixed
* Reference for the variable.
*/
public function &getByReference(string $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. |