Collects services to add/inject them into a consumer service.
This mechanism allows a service to get multiple processor services injected, in order to establish an extensible architecture.
It differs from the factory pattern in that processors are not lazily instantiated on demand; the consuming service receives instances of all registered processors when it is instantiated. Unlike a factory service, the consuming service is not ContainerAware.
It differs from plugins in that all processors are explicitly registered by service providers (driven by declarative configuration in code); the mere availability of a processor (cf. plugin discovery) does not imply that a processor ought to be registered and used.
It differs from regular service definition arguments (constructor injection) in that a consuming service MAY allow further processors to be added dynamically at runtime. This is why the called method (optionally) receives the priority of a processor as second argument.
Hierarchy
- class \Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass implements CompilerPassInterface
See also
\Drupal\Core\DependencyInjection\Compiler\TaggedHandlersPass::process()
File
- core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php, line 33
Namespace
Drupal\Core\DependencyInjection\Compiler
Members
Name | Modifiers | Type | Description |
---|---|---|---|
TaggedHandlersPass::process | public | function | Finds services tagged with 'service_collector', then finds all corresponding tagged services and adds a method call for each to the consuming/collecting service definition. Overrides CompilerPassInterface::process |
Please login to continue.