class TaggedHandlersPass

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

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!DependencyInjection!Compiler!TaggedHandlersPass.php/class/TaggedHandlersPass/8.1.x