public function process(ContainerBuilder $container) { // Loop through all the context_consumer tags and add the contexts via injection $taggedServices = $container->findTaggedServiceIds('context_consumer'); foreach ($taggedServices as $id => $serviceTags) { Validators::validateInterfaceImplemented($container, $id, 'TechData\\ContextDiBundle\\Interfaces\\ContextConsumerInterface'); $service = $container->getDefinition($id); foreach ($serviceTags as $tag) { Validators::validateArrayKeyExists('context_name', $tag); $service->addMethodCall('addContext', array($this->getServiceFactory($container, $tag['context_name']))); } } }
public function process(ContainerBuilder $container) { // Get the reference for the handler service $handlerReference = $container->getDefinition('tech_data_context_di.context_handler'); // Loop through all the context_provider tags and add the services to the context handler service $taggedServices = $container->findTaggedServiceIds('context_provider'); foreach ($taggedServices as $id => $serviceTags) { Validators::validateInterfaceImplemented($container, $id, 'TechData\\ContextDiBundle\\Interfaces\\ContextProviderInterface'); foreach ($serviceTags as $tag) { Validators::validateArrayKeyExists('context_name', $tag); $handlerReference->addMethodCall('addProvider', array(new Reference($id), $tag['context_name'])); } } }