findTaggedServiceIds() public method

Example: $container->register('foo')->addTag('my.tag', array('hello' => 'world')); $serviceIds = $container->findTaggedServiceIds('my.tag'); foreach ($serviceIds as $serviceId => $tags) { foreach ($tags as $tag) { echo $tag['hello']; } }
public findTaggedServiceIds ( string $name ) : array
$name string The tag name
return array An array of tags with the tagged service as key, holding a list of attribute arrays
Example #1
0
 /**
  * Register Drupal drivers.
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('drupal.drupal')) {
         return;
     }
     $drupalDefinition = $container->getDefinition('drupal.drupal');
     foreach ($container->findTaggedServiceIds('drupal.driver') as $id => $attributes) {
         foreach ($attributes as $attribute) {
             if (isset($attribute['alias']) && ($name = $attribute['alias'])) {
                 $drupalDefinition->addMethodCall('registerDriver', array($name, new Reference($id)));
             }
         }
         // If this is Drupal Driver, then a core controller needs to be
         // instantiated as well.
         if ('drupal.driver.drupal' === $id) {
             $drupalDriverDefinition = $container->getDefinition($id);
             $availableCores = array();
             foreach ($container->findTaggedServiceIds('drupal.core') as $coreId => $coreAttributes) {
                 foreach ($coreAttributes as $attribute) {
                     if (isset($attribute['alias']) && ($name = $attribute['alias'])) {
                         $availableCores[$name] = $container->getDefinition($coreId);
                     }
                 }
             }
             $drupalDriverDefinition->addMethodCall('setCore', array($availableCores));
         }
     }
     $drupalDefinition->addMethodCall('setDefaultDriverName', array($container->getParameter('drupal.drupal.default_driver')));
 }
 public function testTaggedService()
 {
     $config = array('standard' => array('region' => '<region name>'));
     $this->extension->load(array(), $this->container);
     $this->extension->load(array($config), $this->container);
     $this->assertEquals(2, count($this->container->findTaggedServiceIds('platinum_pixs_aws')));
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $universalExtensions = array();
     foreach ($container->findTaggedServiceIds('sonata.admin.extension') as $id => $tags) {
         foreach ($tags as $attributes) {
             $target = false;
             if (isset($attributes['target'])) {
                 $target = $attributes['target'];
             }
             if (isset($attributes['global']) && $attributes['global']) {
                 $universalExtensions[] = $id;
             }
             if (!$target || !$container->hasDefinition($target)) {
                 continue;
             }
             $container->getDefinition($target)->addMethodCall('addExtension', array(new Reference($id)));
         }
     }
     $extensionConfig = $container->getParameter('sonata.admin.extension.map');
     $extensionMap = $this->flattenExtensionConfiguration($extensionConfig);
     foreach ($container->findTaggedServiceIds('sonata.admin') as $id => $attributes) {
         $admin = $container->getDefinition($id);
         foreach ($universalExtensions as $extension) {
             $admin->addMethodCall('addExtension', array(new Reference($extension)));
         }
         $extensions = $this->getExtensionsForAdmin($id, $admin, $container, $extensionMap);
         foreach ($extensions as $extension) {
             if (!$container->has($extension)) {
                 throw new \InvalidArgumentException(sprintf('Unable to find extension service for id %s', $extension));
             }
             $admin->addMethodCall('addExtension', array(new Reference($extension)));
         }
     }
 }
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('security.expressions.compiler')) {
         return;
     }
     $compilerDef = $container->getDefinition('security.expressions.compiler');
     foreach ($container->findTaggedServiceIds('security.expressions.function_compiler') as $id => $attr) {
         $compilerDef->addMethodCall('addFunctionCompiler', array(new Reference($id)));
     }
     foreach ($container->findTaggedServiceIds('security.expressions.type_compiler') as $id => $attr) {
         $compilerDef->addMethodCall('addTypeCompiler', array(new Reference($id)));
     }
     $serviceMap = $parameterMap = array();
     foreach ($container->findTaggedServiceIds('security.expressions.variable') as $id => $attributes) {
         foreach ($attributes as $attr) {
             if (!isset($attr['variable']) || !isset($attr['service']) && !isset($attr['parameter'])) {
                 throw new RuntimeException(sprintf('"variable", and either "service" or "parameter" must be given for tag "security.expressions.variable" for service id "%s".', $id));
             }
             if (isset($attr['service'])) {
                 $serviceMap[$attr['variable']] = $attr['service'];
                 $container->findDefinition($attr['service'])->setPublic(true);
             } else {
                 $parameterMap[$attr['variable']] = $attr['parameter'];
             }
         }
     }
     $container->getDefinition('security.expressions.variable_compiler')->addMethodCall('setMaps', array($serviceMap, $parameterMap));
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasParameter($this->connections)) {
         return;
     }
     $this->container = $container;
     $this->connections = $container->getParameter($this->connections);
     $sortFunc = function ($a, $b) {
         $a = isset($a['priority']) ? $a['priority'] : 0;
         $b = isset($b['priority']) ? $b['priority'] : 0;
         return $a > $b ? -1 : 1;
     };
     $subscribersPerCon = $this->groupByConnection($container->findTaggedServiceIds($this->tagPrefix . '.event_subscriber'));
     foreach ($subscribersPerCon as $con => $subscribers) {
         $em = $this->getEventManager($con);
         uasort($subscribers, $sortFunc);
         foreach ($subscribers as $id => $instance) {
             $em->addMethodCall('addEventSubscriber', array(new Reference($id)));
         }
     }
     $listenersPerCon = $this->groupByConnection($container->findTaggedServiceIds($this->tagPrefix . '.event_listener'), true);
     foreach ($listenersPerCon as $con => $listeners) {
         $em = $this->getEventManager($con);
         uasort($listeners, $sortFunc);
         foreach ($listeners as $id => $instance) {
             $em->addMethodCall('addEventListener', array(array_unique($instance['event']), isset($instance['lazy']) && $instance['lazy'] ? $id : new Reference($id)));
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     // add inference types
     $inferenceTypeContainer = $container->getDefinition('rezzza.ruler.inference_type_container');
     foreach ($container->findTaggedServiceIds('rezzza.ruler.inference_type') as $id => $tagAttributes) {
         $inferenceTypeContainer->addMethodCall('add', array(new Reference($id)));
     }
     // add events
     $eventDatas = $container->getParameter('rezzza.ruler.events');
     $eventContainer = $container->getDefinition('rezzza.ruler.event.container');
     $events = array();
     foreach ($eventDatas as $key => $data) {
         $event = new Definition('Rezzza\\RulerBundle\\Ruler\\Event\\Event', array($key, $data['label'], $data['context_builder']));
         $events[$key] = $event;
         $eventContainer->addMethodCall('add', array($event));
     }
     // add inferences
     $inferenceDatas = $container->getParameter('rezzza.ruler.inferences');
     $inferenceContainer = $container->getDefinition('rezzza.ruler.inference_container');
     foreach ($inferenceDatas as $key => $data) {
         $inference = new Definition('Rezzza\\RulerBundle\\Ruler\\Inference\\Inference', array($key, $data['type'], $data['description'], $data['event']));
         foreach ($data['event'] as $event) {
             if (!isset($events[$event])) {
                 throw new \LogicException(sprintf('Event "%s" is not defined', $event));
             }
             $events[$event]->addMethodCall('addInference', array($inference));
         }
         $inferenceContainer->addMethodCall('add', array($inference));
     }
     /* --- functions --- */
     $rulerDefinition = $container->getDefinition('rezzza.ruler');
     foreach ($container->findTaggedServiceIds('rezzza.ruler.functions') as $id => $tagAttributes) {
         $rulerDefinition->addMethodCall('addFunctionCollection', array(new Reference($id)));
     }
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $tag = 'twig.environment';
     $defs = array();
     foreach ($container->findTaggedServiceIds($tag) as $id => $tags) {
         foreach ($tags as $attributes) {
             $type = $this->getTypeFromAttributes($attributes);
             $defs[$type] = $container->getDefinition($id);
         }
     }
     $method = 'addExtension';
     $prefix = 'twig.environment.';
     $tag = 'twig.extension';
     foreach ($container->findTaggedServiceIds($tag) as $id => $tags) {
         foreach ($tags as $attributes) {
             $type = $this->getTypeFromAttributes($attributes);
             $args = array(new Reference($id));
             if (in_array($type, array_keys($defs))) {
                 $defs[$type]->addMethodCall($method, $args);
             } elseif ($type === 'all') {
                 foreach ($defs as $def) {
                     $def->addMethodCall($method, $args);
                 }
             } else {
                 throw new \InvalidArgumentException("Invalid twig environment type '{$type}'.");
             }
         }
     }
 }
    /**
     * {@inheritDoc}
     */
    public function process(ContainerBuilder $container)
    {

        // ListBuilder
        $definition = $container->getDefinition('sonata.admin.guesser.orm_list_chain');
        $services = array();
        foreach($container->findTaggedServiceIds('sonata.admin.guesser.orm_list') as $id => $attributes) {
            $services[] = new Reference($id);
        }

        $definition->replaceArgument(0, $services);

        // ListBuilder
        $definition = $container->getDefinition('sonata.admin.guesser.orm_datagrid_chain');
        $services = array();
        foreach($container->findTaggedServiceIds('sonata.admin.guesser.orm_datagrid') as $id => $attributes) {
            $services[] = new Reference($id);
        }

        $definition->replaceArgument(0, $services);

        // ShowBuilder
        $definition = $container->getDefinition('sonata.admin.guesser.orm_show_chain');
        $services = array();
        foreach($container->findTaggedServiceIds('sonata.admin.guesser.orm_show') as $id => $attributes) {
            $services[] = new Reference($id);
        }

        $definition->replaceArgument(0, $services);
    }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     // loaders
     $loaders = array();
     $loadersReferences = array();
     foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
         $loaders[$id][] = $attributes[0]['alias'];
         $loadersReferences[$attributes[0]['alias']] = new Reference($id);
         if (isset($attributes[0]['legacy-alias'])) {
             $loaders[$id][] = $attributes[0]['legacy-alias'];
             $loadersReferences[$attributes[0]['legacy-alias']] = new Reference($id);
         }
     }
     if ($container->hasDefinition('lexik_translation.translator')) {
         $container->findDefinition('lexik_translation.translator')->replaceArgument(2, $loaders);
     }
     if ($container->hasDefinition('lexik_translation.importer.file')) {
         $container->findDefinition('lexik_translation.importer.file')->replaceArgument(0, $loadersReferences);
     }
     // exporters
     if ($container->hasDefinition('lexik_translation.exporter_collector')) {
         foreach ($container->findTaggedServiceIds('lexik_translation.exporter') as $id => $attributes) {
             $container->getDefinition('lexik_translation.exporter_collector')->addMethodCall('addExporter', array($id, new Reference($id)));
         }
     }
 }
 /**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  *
  * @throws \LogicException
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('ezpublish.field_type_collection.factory')) {
         return;
     }
     $fieldTypeCollectionFactoryDef = $container->getDefinition('ezpublish.field_type_nameable_collection.factory');
     $nameableFieldTypes = [];
     // Nameable Field types.
     // Alias attribute is the field type string.
     foreach ($container->findTaggedServiceIds('ezpublish.fieldType.nameable') as $id => $attributes) {
         foreach ($attributes as $attribute) {
             if (!isset($attribute['alias'])) {
                 throw new LogicException('ezpublish.fieldType service tag needs an "alias" attribute to identify the field type. None given.');
             }
             $fieldTypeCollectionFactoryDef->addMethodCall('registerNameableFieldType', array($id, $attribute['alias']));
             $nameableFieldTypes[] = $attribute['alias'];
         }
     }
     // Field types, loop over and detect those that are missing nameable service.
     // Alias attribute is the field type string.
     foreach ($container->findTaggedServiceIds('ezpublish.fieldType') as $id => $attributes) {
         foreach ($attributes as $attribute) {
             if (!isset($attribute['alias'])) {
                 throw new LogicException('ezpublish.fieldType service tag needs an "alias" attribute to identify the field type. None given.');
             }
             if (in_array($attribute['alias'], $nameableFieldTypes)) {
                 continue;
             }
             $fieldTypeCollectionFactoryDef->addMethodCall('registerNonNameableFieldType', array($id, $attribute['alias']));
         }
     }
 }
Example #11
0
 public function process(ContainerBuilder $c)
 {
     // tagged resource providers
     $builder = $c->getDefinition('acl.resource.builder');
     foreach ($c->findTaggedServiceIds('acl.resource.provider') as $id => $attributes) {
         $builder->addMethodCall('provider', [new Reference($id)]);
     }
     // tagged access resource providers
     $decisionManager = $c->getDefinition('acl.access.decision_manager');
     foreach ($c->findTaggedServiceIds('acl.policy.provider') as $id => $attributes) {
         $decisionManager->addMethodCall('provider', [new Reference($id)]);
     }
     // resource transformations
     $transformator = $c->getDefinition('acl.resource.transformator');
     $refs = [];
     foreach ($c->findTaggedServiceIds('acl.resource.transformer') as $id => $attributes) {
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $refs[$id] = $priority;
     }
     arsort($refs);
     // inverse sort, lowest priority is last
     foreach ($refs as $id => $p) {
         $transformator->addArgument(new Reference($id));
     }
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$this->integrationExtension->isNotifierEnabled()) {
         if (count($container->findTaggedServiceIds('notifier.sender.strategy')) > 0) {
             throw new \RuntimeException('Could not compile notifier sender strategy, because system is not enabled.');
         }
         return;
     }
     $strategyManagerDefinition = $container->findDefinition('notifier.sender_strategy_manager');
     foreach ($container->findTaggedServiceIds('notifier.sender.strategy') as $id => $tags) {
         $definition = $container->getDefinition($id);
         $class = $definition->getClass();
         try {
             $class = $container->getParameterBag()->resolveValue($class);
             $refClass = new \ReflectionClass($class);
             $requiredInterface = 'FivePercent\\Component\\Notifier\\SenderStrategy\\SenderStrategyInterface';
             if (!$refClass->implementsInterface($requiredInterface)) {
                 throw new \RuntimeException(sprintf('The notifier sender strategy should implement "%s" interface.', $requiredInterface));
             }
             foreach ($tags as $index => $attributes) {
                 if (empty($attributes['key'])) {
                     throw new \RuntimeException(sprintf('The "key" parameter for tag with index "%d" must be a specified.', $index));
                 }
                 $strategyManagerDefinition->addMethodCall('addStrategy', [$attributes['key'], new Reference($id)]);
             }
         } catch (\Exception $e) {
             throw new \RuntimeException(sprintf('Could not compile notifier sender strategy with service id "%s".', $id), 0, $e);
         }
     }
 }
Example #13
0
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('form.extension')) {
         return;
     }
     $definition = $container->getDefinition('form.extension');
     // Builds an array with fully-qualified type class names as keys and service IDs as values
     $types = array();
     foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
         // Support type access by FQCN
         $serviceDefinition = $container->getDefinition($serviceId);
         $types[$serviceDefinition->getClass()] = $serviceId;
     }
     $definition->replaceArgument(1, $types);
     $typeExtensions = array();
     foreach ($container->findTaggedServiceIds('form.type_extension') as $serviceId => $tag) {
         if (isset($tag[0]['extended_type'])) {
             $extendedType = $tag[0]['extended_type'];
         } else {
             throw new \InvalidArgumentException(sprintf('Tagged form type extension must have the extended type configured using the extended_type/extended-type attribute, none was configured for the "%s" service.', $serviceId));
         }
         $typeExtensions[$extendedType][] = $serviceId;
     }
     $definition->replaceArgument(2, $typeExtensions);
     // Find all services annotated with "form.type_guesser"
     $guessers = array_keys($container->findTaggedServiceIds('form.type_guesser'));
     $definition->replaceArgument(3, $guessers);
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $gatewayFactory = $container->getDefinition('payum.core_gateway_factory');
     $gatewayFactory->replaceArgument(0, $container->findTaggedServiceIds('payum.action'));
     $gatewayFactory->replaceArgument(1, $container->findTaggedServiceIds('payum.extension'));
     $gatewayFactory->replaceArgument(2, $container->findTaggedServiceIds('payum.api'));
 }
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('templating.engine')) {
         return;
     }
     $renderers = array();
     foreach ($container->findTaggedServiceIds('templating.renderer') as $id => $attributes) {
         if (isset($attributes[0]['alias'])) {
             $renderers[$attributes[0]['alias']] = new Reference($id);
             $container->getDefinition($id)->addMethodCall('setEngine', array(new Reference('templating.engine')));
         }
     }
     $helpers = array();
     foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
         if (isset($attributes[0]['alias'])) {
             $helpers[$attributes[0]['alias']] = $id;
         }
     }
     $definition = $container->getDefinition('templating.engine');
     $arguments = $definition->getArguments();
     $arguments[2] = $renderers;
     $definition->setArguments($arguments);
     if (count($helpers) > 0) {
         $definition->addMethodCall('setHelpers', array($helpers));
     }
 }
 private function buildUseCaseProxies()
 {
     $taggedServices = $this->container->findTaggedServiceIds('openclassrooms.use_case');
     foreach ($taggedServices as $taggedServiceName => $tagParameters) {
         $this->buildUseCaseProxyFactoryDefinition($taggedServiceName, $tagParameters);
     }
 }
Example #17
0
 public function process(ContainerBuilder $container)
 {
     $tags = $container->findTaggedServiceIds('cmf_media.upload_editor_helper');
     if (count($tags) > 0) {
         if ($container->has('cmf_media.upload_file_helper')) {
             $manager = $container->findDefinition('cmf_media.upload_file_helper');
             foreach ($tags as $id => $tag) {
                 $manager->addMethodCall('addEditorHelper', array($tag[0]['alias'], new Reference($id)));
             }
         }
         if ($container->has('cmf_media.upload_image_helper')) {
             $manager = $container->findDefinition('cmf_media.upload_image_helper');
             foreach ($tags as $id => $tag) {
                 $manager->addMethodCall('addEditorHelper', array($tag[0]['alias'], new Reference($id)));
             }
         }
     }
     $tags = $container->findTaggedServiceIds('cmf_media.browser_file_helper');
     if (count($tags) > 0) {
         if ($container->has('cmf_media.browser_file_helper')) {
             $manager = $container->findDefinition('cmf_media.browser_file_helper');
             foreach ($tags as $id => $tag) {
                 $manager->addMethodCall('addEditorHelper', array($tag[0]['editor'], $tag[0]['browser'], new Reference($id)));
             }
         }
     }
 }
Example #18
0
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $registry = $container->getDefinition('payum.static_registry');
     $gatewaysIds = array();
     foreach ($container->findTaggedServiceIds('payum.gateway') as $gatewaysId => $tagAttributes) {
         foreach ($tagAttributes as $attributes) {
             $gatewaysIds[$attributes['gateway']] = $gatewaysId;
         }
     }
     $storagesIds = array();
     foreach ($container->findTaggedServiceIds('payum.storage') as $storageId => $tagAttributes) {
         foreach ($tagAttributes as $attributes) {
             $storagesIds[$attributes['model_class']] = $storageId;
         }
     }
     $availableGatewayFactories = array();
     $gatewaysFactoriesIds = array();
     foreach ($container->findTaggedServiceIds('payum.gateway_factory') as $gatewayFactoryId => $tagAttributes) {
         foreach ($tagAttributes as $attributes) {
             $gatewaysFactoriesIds[$attributes['name']] = $gatewayFactoryId;
             $availableGatewayFactories[$attributes['name']] = isset($attributes['human_name']) ? $attributes['human_name'] : $attributes['name'];
         }
     }
     $container->setParameter('payum.available_gateway_factories', array_replace($availableGatewayFactories, $container->getParameter('payum.available_gateway_factories')));
     $registry->replaceArgument(0, $gatewaysIds);
     $registry->replaceArgument(1, $storagesIds);
     $registry->replaceArgument(2, $gatewaysFactoriesIds);
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$this->integrationExtension->isVarTagValidatorEnabled()) {
         if (count($container->findTaggedServiceIds('validator.var_tag.constraint_factory')) > 0) {
             throw new \RuntimeException('Could not compile var tag validator constraint factory, because system is not enabled.');
         }
         return;
     }
     $registryDefinition = $container->getDefinition('validator.var_tag.constraint_factory_registry');
     foreach ($container->findTaggedServiceIds('validator.var_tag.constraint_factory') as $id => $tags) {
         $factoryDefinition = $container->getDefinition($id);
         $class = $factoryDefinition->getClass();
         try {
             $class = $container->getParameterBag()->resolveValue($class);
             $refClass = new \ReflectionClass($class);
             $requiredInterface = 'FivePercent\\Component\\VarTagValidator\\Constraint\\ConstraintFactoryInterface';
             if (!$refClass->implementsInterface($requiredInterface)) {
                 throw new \RuntimeException(sprintf('The var tag constraint factory should implement "%s" interface.', $requiredInterface));
             }
             foreach ($tags as $attributes) {
                 if (empty($attributes['type'])) {
                     throw new \RuntimeException('Missing attribute "type".');
                 }
                 $registryDefinition->addMethodCall('addConstraintFactory', [$attributes['type'], new Reference($id)]);
             }
         } catch (\Exception $e) {
             throw new \RuntimeException(sprintf('Could not compile var tag validator constraint factory with service id "%s".', $id));
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$this->integrationExtension->isModelTransformerEnabled()) {
         if (count($container->findTaggedServiceIds('model_transformer'))) {
             throw new \RuntimeException('Could not compile model transformer, because system is not enabled.');
         }
         return;
     }
     $transformerManagerDefinition = $container->getDefinition('model_transformer');
     foreach ($container->findTaggedServiceIds('model_transformer') as $id => $tags) {
         $attributes = $this->fixAttributes($tags);
         $attributes += ['priority' => 0];
         $definition = $container->getDefinition($id);
         $class = $definition->getClass();
         try {
             $class = $container->getParameterBag()->resolveValue($class);
             $refClass = new \ReflectionClass($class);
             $requiredInterface = 'FivePercent\\Component\\ModelTransformer\\ModelTransformerInterface';
             if (!$refClass->implementsInterface($requiredInterface)) {
                 throw new \RuntimeException(sprintf('The model transformer should implement "%s" interface.', $requiredInterface));
             }
         } catch (\Exception $e) {
             throw new \RuntimeException(sprintf('Could not compile model transformer with service id "%s".', $id), 0, $e);
         }
         $transformerManagerDefinition->addMethodCall('addTransformer', [new Reference($id), $attributes['priority']]);
     }
 }
 /**
  * You can modify the container here before it is dumped to PHP code.
  *
  * @param ContainerBuilder $container
  *
  * @api
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition("thelia.form_factory_builder")) {
         return;
     }
     $formFactoryBuilderDefinition = $container->getDefinition("thelia.form_factory_builder");
     /**
      * Add form extensions
      */
     foreach ($container->findTaggedServiceIds("thelia.forms.extension") as $id => $definition) {
         $formFactoryBuilderDefinition->addMethodCall("addExtension", [new Reference($id)]);
     }
     /**
      * And form types
      */
     foreach ($container->findTaggedServiceIds("thelia.form.type") as $id => $definition) {
         $formFactoryBuilderDefinition->addMethodCall("addType", [new Reference($id)]);
     }
     /**
      * And form type extensions
      */
     foreach ($container->findTaggedServiceIds("thelia.form.type_extension") as $id => $definition) {
         $formFactoryBuilderDefinition->addMethodCall("addTypeExtension", [new Reference($id)]);
     }
 }
 public function process(ContainerBuilder $container)
 {
     $connections = $container->findTaggedServiceIds('neoclient.registered_connection');
     $connectionManager = $container->findDefinition('neoclient.connection_manager');
     $fallbacks = $container->findTaggedServiceIds('neoclient.fallback_connection');
     foreach ($connections as $id => $params) {
         $def = $container->getDefinition($id);
         if ($def->hasTag('neoclient.ha_master')) {
             if (null !== $this->master) {
                 throw new \RuntimeException('Having two connections registered as master is not permitted');
             }
             $this->master = $def->getArgument(0);
         }
         if ($def->hasTag('neoclient.ha_slave')) {
             $this->slaves[] = $def->getArgument(0);
         }
         $connectionManager->addMethodCall('registerConnection', array($container->getDefinition($id)));
     }
     foreach ($fallbacks as $id => $params) {
         $connectionManager->addMethodCall('setFallbackConnection', array($params[0]['fallback_of'], $params[0]['connection_alias']));
     }
     if (null !== $this->master) {
         $connectionManager->addMethodCall('setMasterConnection', array($this->master));
     }
     if (!empty($this->slaves)) {
         $connectionManager->addMethodCall('setSlaveConnections', array($this->slaves));
     }
 }
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition($this->dispatcherService)) {
         return;
     }
     $definition = $container->getDefinition($this->dispatcherService);
     foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
         foreach ($events as $event) {
             $priority = isset($event['priority']) ? $event['priority'] : 0;
             if (!isset($event['event'])) {
                 throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "kernel.event_listener" tags.', $id));
             }
             if (!isset($event['method'])) {
                 $event['method'] = 'on' . preg_replace_callback(array('/(?<=\\b)[a-z]/i', '/[^a-z0-9]/i'), function ($matches) {
                     return strtoupper($matches[0]);
                 }, $event['event']);
                 $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']);
             }
             $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority));
         }
     }
     foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) {
         // We must assume that the class value has been correctly filled, even if the service is created by a factory
         $class = $container->getDefinition($id)->getClass();
         $refClass = new \ReflectionClass($class);
         $interface = 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface';
         if (!$refClass->implementsInterface($interface)) {
             throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface));
         }
         $definition->addMethodCall('addSubscriberService', array($id, $class));
     }
 }
Example #24
0
 public function process(ContainerBuilder $container)
 {
     if ($container->hasDefinition('templating')) {
         return;
     }
     if ($container->hasDefinition('templating.engine.php')) {
         $helpers = array();
         foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
             if (isset($attributes[0]['alias'])) {
                 $helpers[$attributes[0]['alias']] = $id;
             }
         }
         $definition = $container->getDefinition('templating.engine.php');
         $arguments = $definition->getArguments();
         $definition->setArguments($arguments);
         if (count($helpers) > 0) {
             $definition->addMethodCall('setHelpers', array($helpers));
         }
     }
     if ($container->hasDefinition('templating.engine.delegating')) {
         $queue = new \SplPriorityQueue();
         foreach ($container->findTaggedServiceIds('templating.engine') as $id => $attributes) {
             $queue->insert($id, isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0);
         }
         $engines = array();
         foreach ($queue as $engine) {
             $engines[] = $engine;
         }
         $container->getDefinition('templating.engine.delegating')->addMethodCall('setEngineIds', array($engines));
     }
 }
Example #25
0
 /**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container The container.
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('rezzza_jobflow.extensions')) {
         return;
     }
     $definition = $container->getDefinition('rezzza_jobflow.extensions');
     // Builds an array with service IDs as keys and tag aliases as values
     $types = array();
     foreach ($container->findTaggedServiceIds('jobflow.type') as $serviceId => $tag) {
         $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
         // Flip, because we want tag aliases (= type identifiers) as keys
         $types[$alias] = $serviceId;
     }
     $definition->replaceArgument(1, $types);
     $extensions = array();
     foreach ($container->findTaggedServiceIds('jobflow.extension') as $serviceId => $tag) {
         $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
         $extensions[$alias][] = $serviceId;
     }
     $definition->replaceArgument(2, $extensions);
     $transports = array();
     foreach ($container->findTaggedServiceIds('jobflow.transport') as $serviceId => $tag) {
         $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
         $transports[$alias] = $serviceId;
     }
     $definition->replaceArgument(3, $transports);
 }
Example #26
0
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('form.extension')) {
         return;
     }
     $definition = $container->getDefinition('form.extension');
     // Builds an array with service IDs as keys and tag aliases as values
     $types = array();
     foreach ($container->findTaggedServiceIds('form.type') as $serviceId => $tag) {
         // The following if-else block is deprecated and will be removed
         // in Symfony 3.0
         // Deprecation errors are triggered in the form registry
         if (isset($tag[0]['alias'])) {
             $types[$tag[0]['alias']] = $serviceId;
         } else {
             $types[$serviceId] = $serviceId;
         }
         // Support type access by FQCN
         $serviceDefinition = $container->getDefinition($serviceId);
         $types[$serviceDefinition->getClass()] = $serviceId;
     }
     $definition->replaceArgument(1, $types);
     $typeExtensions = array();
     foreach ($container->findTaggedServiceIds('form.type_extension') as $serviceId => $tag) {
         $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId;
         $typeExtensions[$alias][] = $serviceId;
     }
     $definition->replaceArgument(2, $typeExtensions);
     // Find all services annotated with "form.type_guesser"
     $guessers = array_keys($container->findTaggedServiceIds('form.type_guesser'));
     $definition->replaceArgument(3, $guessers);
 }
 /**
  * Adds services to the Serializer.
  *
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  *   The container to process.
  */
 public function process(ContainerBuilder $container)
 {
     $definition = $container->getDefinition('serializer');
     // Retrieve registered Normalizers and Encoders from the container.
     foreach ($container->findTaggedServiceIds('normalizer') as $id => $attributes) {
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $normalizers[$priority][] = new Reference($id);
     }
     foreach ($container->findTaggedServiceIds('encoder') as $id => $attributes) {
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $encoders[$priority][] = new Reference($id);
     }
     // Add the registered Normalizers and Encoders to the Serializer.
     if (!empty($normalizers)) {
         $definition->replaceArgument(0, $this->sort($normalizers));
     }
     if (!empty($encoders)) {
         $definition->replaceArgument(1, $this->sort($encoders));
     }
     // Find all serialization formats known.
     $formats = array();
     foreach ($container->findTaggedServiceIds('encoder') as $attributes) {
         $formats[] = $attributes[0]['format'];
     }
     $container->setParameter('serializer.formats', $formats);
 }
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition('assetic.asset_manager')) {
         return;
     }
     $am = $container->getDefinition('assetic.asset_manager');
     // add assets
     foreach ($container->findTaggedServiceIds('assetic.asset') as $id => $attributes) {
         foreach ($attributes as $attr) {
             if (isset($attr['alias'])) {
                 $am->addMethodCall('set', array($attr['alias'], new Reference($id)));
             }
         }
     }
     // add loaders
     $loaders = array();
     foreach ($container->findTaggedServiceIds('assetic.formula_loader') as $id => $attributes) {
         foreach ($attributes as $attr) {
             if (isset($attr['alias'])) {
                 $loaders[$attr['alias']] = new Reference($id);
             }
         }
     }
     $am->replaceArgument(1, $loaders);
     // add resources
     foreach ($container->findTaggedServiceIds('assetic.formula_resource') as $id => $attributes) {
         foreach ($attributes as $attr) {
             if (isset($attr['loader'])) {
                 $am->addMethodCall('addResource', array(new Reference($id), $attr['loader']));
             }
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $typeIdx = array();
     foreach ($container->findTaggedServiceIds('form.type') as $id => $tags) {
         $typeIdx[] = $id;
     }
     $typeExtensionIdx = array();
     foreach ($container->findTaggedServiceIds('form.type_extension') as $id => $tag) {
         $typeExtensionIdx[] = $id;
     }
     $container->setParameter('sonata.core.form.types', $typeIdx);
     $container->setParameter('sonata.core.form.type_extensions', $typeExtensionIdx);
     // nothing to do
     if (!$container->hasDefinition('sonata.core.form.extension.dependency')) {
         return;
     }
     // get factories
     $original = $container->getDefinition('form.extension');
     $factory = $container->getDefinition('sonata.core.form.extension.dependency');
     $factory->replaceArgument(1, $original->getArgument(1));
     $factory->replaceArgument(2, $original->getArgument(2));
     $factory->replaceArgument(3, $original->getArgument(3));
     $container->removeDefinition('form.extension');
     $container->removeDefinition('sonata.core.form.extension.dependency');
     $container->setDefinition('form.extension', $factory);
 }
 /**
  * getListenersIds
  *
  * Searches for any number of defined listeners under the tag "*.event_listener"
  *
  * @return array listeners ids
  */
 protected function getListenersIds()
 {
     $listenersIds = array();
     if (!$this->containerBuilder->hasDefinition('event_dispatcher')) {
         return $listenersIds;
     }
     $definition = $this->containerBuilder->getDefinition('event_dispatcher');
     $dfs = $this->containerBuilder->getDefinitions();
     foreach ($dfs as $k => $v) {
         $tags = $v->getTags();
         if (count($tags) <= 0) {
             continue;
         }
         $keys = array_keys($tags);
         $tag = $keys[0];
         if (preg_match('/.+\\.event_listener/', $tag)) {
             $services = $this->containerBuilder->findTaggedServiceIds($tag);
             foreach ($services as $id => $events) {
                 $this->listeners[$id]['tag'] = $tags[$tag][0];
                 $listenersIds[$id] = $id;
             }
         }
     }
     return $listenersIds;
 }