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']));
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     // Get the available contexts from the config
     $availableContexts = array();
     if (isset($config['available_contexts']) && is_array($config['available_contexts'])) {
         $availableContexts = $config['available_contexts'];
     }
     // Add the possible contexts to the container for later use
     $container->setParameter('tech_data_context_di.context_handler.available_contexts', $availableContexts);
     // Add an alias to the configured cache
     if (!$container->hasDefinition($config['cache_service'])) {
         throw new \RuntimeException('Unable to locate service with name "' . $config['cache_service'] . '".');
     }
     // Make sure the class implements the interface
     Validators::validateInterfaceImplemented($container, $config['cache_service'], 'TechData\\ContextDiBundle\\Interfaces\\ContextCacheInterface');
     $container->setAlias('tech_data_context_di.cache', $config['cache_service']);
 }