final class PreprocessEventFactoryMapper in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/preprocess_event_dispatcher/src/Service/PreprocessEventFactoryMapper.php \Drupal\preprocess_event_dispatcher\Service\PreprocessEventFactoryMapper
Class PreprocessEventFactoryMapper.
Hierarchy
- class \Drupal\preprocess_event_dispatcher\Service\PreprocessEventFactoryMapper
Expanded class hierarchy of PreprocessEventFactoryMapper
1 file declares its use of PreprocessEventFactoryMapper
- YamlDefinitionsLoader.php in modules/
preprocess_event_dispatcher/ tests/ src/ Unit/ Helpers/ YamlDefinitionsLoader.php
1 string reference to 'PreprocessEventFactoryMapper'
- preprocess_event_dispatcher.services.yml in modules/
preprocess_event_dispatcher/ preprocess_event_dispatcher.services.yml - modules/preprocess_event_dispatcher/preprocess_event_dispatcher.services.yml
1 service uses PreprocessEventFactoryMapper
- preprocess_event.factory_mapper in modules/
preprocess_event_dispatcher/ preprocess_event_dispatcher.services.yml - Drupal\preprocess_event_dispatcher\Service\PreprocessEventFactoryMapper
File
- modules/
preprocess_event_dispatcher/ src/ Service/ PreprocessEventFactoryMapper.php, line 10
Namespace
Drupal\preprocess_event_dispatcher\ServiceView source
final class PreprocessEventFactoryMapper {
/**
* Map that binds a hook to a factory.
*
* @var \Drupal\preprocess_event_dispatcher\Factory\PreprocessEventFactoryInterface[]
*/
private $hookToFactoryMap = [];
/**
* Add Factory to the mapper.
*
* @param \Drupal\preprocess_event_dispatcher\Factory\PreprocessEventFactoryInterface $factory
* Provided factory to add.
*/
public function addFactory(PreprocessEventFactoryInterface $factory) : void {
$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\preprocess_event_dispatcher\Factory\PreprocessEventFactoryInterface|null
* PreprocessEventFactory.
*/
public function getFactory(string $hook) : ?PreprocessEventFactoryInterface {
return $this->hookToFactoryMap[$hook] ?? 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. |