final class PreprocessEventFactoryMapper in Hook Event Dispatcher 8
Class PreprocessEventFactoryMapper.
Hierarchy
- class \Drupal\hook_event_dispatcher\Service\PreprocessEventFactoryMapper
Expanded class hierarchy of PreprocessEventFactoryMapper
1 file declares its use of PreprocessEventFactoryMapper
- YamlDefinitionsLoader.php in tests/
src/ Unit/ Preprocess/ Helpers/ YamlDefinitionsLoader.php
1 string reference to 'PreprocessEventFactoryMapper'
1 service uses PreprocessEventFactoryMapper
File
- src/
Service/ PreprocessEventFactoryMapper.php, line 10
Namespace
Drupal\hook_event_dispatcher\ServiceView source
final class PreprocessEventFactoryMapper {
/**
* Map that binds a hook to a factory.
*
* @var \Drupal\hook_event_dispatcher\Event\Preprocess\Factory\PreprocessEventFactoryInterface[]
*/
private $hookToFactoryMap = [];
/**
* Add Factory to the mapper.
*
* @param \Drupal\hook_event_dispatcher\Event\Preprocess\Factory\PreprocessEventFactoryInterface $factory
* Provided factory to add.
*/
public function addFactory(PreprocessEventFactoryInterface $factory) {
$hook = $factory
->getEventHook();
$this->hookToFactoryMap[$hook] = $factory;
}
/**
* Get a factory with the provided hook or the default factory.
*
* @param string $hook
* The hook name.
*
* @return \Drupal\hook_event_dispatcher\Event\Preprocess\Factory\PreprocessEventFactoryInterface|null
* PreprocessEventFactory.
*/
public function getFactory($hook) {
if (isset($this->hookToFactoryMap[$hook])) {
return $this->hookToFactoryMap[$hook];
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PreprocessEventFactoryMapper:: |
private | property | Map that binds a hook to a factory. | |
PreprocessEventFactoryMapper:: |
public | function | Add Factory to the mapper. | |
PreprocessEventFactoryMapper:: |
public | function | Get a factory with the provided hook or the default factory. |