当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerBuilder::findTaggedServiceIds方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::findTaggedServiceIds方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::findTaggedServiceIds方法的具体用法?PHP ContainerBuilder::findTaggedServiceIds怎么用?PHP ContainerBuilder::findTaggedServiceIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\ContainerBuilder的用法示例。


在下文中一共展示了ContainerBuilder::findTaggedServiceIds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * 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')));
 }
开发者ID:bjeavons,项目名称:probo-test,代码行数:32,代码来源:DriverPass.php

示例2: testTaggedService

 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')));
 }
开发者ID:eexit,项目名称:aws-symfony2-bundle,代码行数:7,代码来源:PlatinumPixsAwsExtensionTest.php

示例3: process

 /**
  * {@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)));
         }
     }
 }
开发者ID:robhunt3r,项目名称:SonataAdminBundle,代码行数:37,代码来源:ExtensionCompilerPass.php

示例4: process

 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));
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:28,代码来源:AddExpressionCompilersPass.php

示例5: process

 /**
  * {@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)));
         }
     }
 }
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:32,代码来源:RegisterEventListenersAndSubscribersPass.php

示例6: process

 /**
  * {@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)));
     }
 }
开发者ID:kmoussouni,项目名称:RulerBundle,代码行数:38,代码来源:BuilderCompilerPass.php

示例7: process

 /**
  * {@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}'.");
             }
         }
     }
 }
开发者ID:miguelibero,项目名称:meinhof,代码行数:32,代码来源:TwigExtensionPass.php

示例8: process

    /**
     * {@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);
    }
开发者ID:nibsirahsieu,项目名称:AdminBundle,代码行数:33,代码来源:AddGuesserCompilerPass.php

示例9: process

 /**
  * {@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)));
         }
     }
 }
开发者ID:StuartApp,项目名称:LexikTranslationBundle,代码行数:29,代码来源:TranslatorPass.php

示例10: process

 /**
  * @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']));
         }
     }
 }
开发者ID:emodric,项目名称:ezpublish-kernel,代码行数:37,代码来源:FieldTypeNameableCollectionPass.php

示例11: process

 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));
     }
 }
开发者ID:data-dog,项目名称:acl-bundle,代码行数:25,代码来源:AclProviderPass.php

示例12: process

 /**
  * {@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);
         }
     }
 }
开发者ID:Gtvar,项目名称:FivePercent-IntegrationBundle,代码行数:33,代码来源:AddNotifierSenderStrategyPass.php

示例13: process

 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);
 }
开发者ID:noikiy,项目名称:symfony,代码行数:28,代码来源:FormPass.php

示例14: process

 /**
  * {@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'));
 }
开发者ID:steffenbrem,项目名称:PayumBundle,代码行数:10,代码来源:BuildGatewayFactoryPass.php

示例15: process

 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));
     }
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:26,代码来源:AddTemplatingRenderersPass.php


注:本文中的Symfony\Component\DependencyInjection\ContainerBuilder::findTaggedServiceIds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。