Loading core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +23 −13 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ */ class TaggedHandlersPass implements CompilerPassInterface { /** * Service tag information keyed by tag name. * * @var array */ protected $tagCache = []; /** * {@inheritdoc} * Loading Loading @@ -89,22 +96,25 @@ class TaggedHandlersPass implements CompilerPassInterface { * If at least one tagged service is required but none are found. */ public function process(ContainerBuilder $container) { // Avoid using ContainerBuilder::findTaggedServiceIds() as that we result in // Avoid using ContainerBuilder::findTaggedServiceIds() as that results in // additional iterations around all the service definitions. foreach ($container->getDefinitions() as $consumer_id => $definition) { $tags = $definition->getTags(); if (isset($tags['service_collector'])) { foreach ($tags['service_collector'] as $pass) { foreach ($container->getDefinitions() as $id => $definition) { foreach ($definition->getTags() as $name => $info) { $this->tagCache[$name][$id] = $info; } } foreach ($this->tagCache['service_collector'] ?? [] as $consumer_id => $tags) { foreach ($tags as $pass) { $this->processServiceCollectorPass($pass, $consumer_id, $container); } } if (isset($tags['service_id_collector'])) { foreach ($tags['service_id_collector'] as $pass) { foreach ($this->tagCache['service_id_collector'] ?? [] as $consumer_id => $tags) { foreach ($tags as $pass) { $this->processServiceIdCollectorPass($pass, $consumer_id, $container); } } } } /** * Processes a service collector service pass. Loading Loading @@ -158,7 +168,7 @@ protected function processServiceCollectorPass(array $pass, $consumer_id, Contai // Find all tagged handlers. $handlers = []; $extra_arguments = []; foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { // Validate the interface. $handler = $container->getDefinition($id); if (!is_subclass_of($handler->getClass(), $interface)) { Loading Loading @@ -218,7 +228,7 @@ protected function processServiceIdCollectorPass(array $pass, $consumer_id, Cont // Find all tagged handlers. $handlers = []; foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; } Loading Loading
core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +23 −13 Original line number Diff line number Diff line Loading @@ -38,6 +38,13 @@ */ class TaggedHandlersPass implements CompilerPassInterface { /** * Service tag information keyed by tag name. * * @var array */ protected $tagCache = []; /** * {@inheritdoc} * Loading Loading @@ -89,22 +96,25 @@ class TaggedHandlersPass implements CompilerPassInterface { * If at least one tagged service is required but none are found. */ public function process(ContainerBuilder $container) { // Avoid using ContainerBuilder::findTaggedServiceIds() as that we result in // Avoid using ContainerBuilder::findTaggedServiceIds() as that results in // additional iterations around all the service definitions. foreach ($container->getDefinitions() as $consumer_id => $definition) { $tags = $definition->getTags(); if (isset($tags['service_collector'])) { foreach ($tags['service_collector'] as $pass) { foreach ($container->getDefinitions() as $id => $definition) { foreach ($definition->getTags() as $name => $info) { $this->tagCache[$name][$id] = $info; } } foreach ($this->tagCache['service_collector'] ?? [] as $consumer_id => $tags) { foreach ($tags as $pass) { $this->processServiceCollectorPass($pass, $consumer_id, $container); } } if (isset($tags['service_id_collector'])) { foreach ($tags['service_id_collector'] as $pass) { foreach ($this->tagCache['service_id_collector'] ?? [] as $consumer_id => $tags) { foreach ($tags as $pass) { $this->processServiceIdCollectorPass($pass, $consumer_id, $container); } } } } /** * Processes a service collector service pass. Loading Loading @@ -158,7 +168,7 @@ protected function processServiceCollectorPass(array $pass, $consumer_id, Contai // Find all tagged handlers. $handlers = []; $extra_arguments = []; foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { // Validate the interface. $handler = $container->getDefinition($id); if (!is_subclass_of($handler->getClass(), $interface)) { Loading Loading @@ -218,7 +228,7 @@ protected function processServiceIdCollectorPass(array $pass, $consumer_id, Cont // Find all tagged handlers. $handlers = []; foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; } Loading