當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Definition::addTag方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\Definition::addTag方法的典型用法代碼示例。如果您正苦於以下問題:PHP Definition::addTag方法的具體用法?PHP Definition::addTag怎麽用?PHP Definition::addTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\Definition的用法示例。


在下文中一共展示了Definition::addTag方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadInitializer

 /**
  * Load the initializer.
  *
  * @param ContainerBuilder    $container
  * @param HttpKernelInterface $app
  */
 private function loadInitializer(ContainerBuilder $container, $app)
 {
     $definition = new Definition('Laracasts\\Behat\\Context\\KernelAwareInitializer', [$app]);
     $definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]);
     $definition->addTag(ContextExtension::INITIALIZER_TAG, ['priority' => 0]);
     $container->setDefinition('laravel.initializer', $definition);
 }
開發者ID:HRcc,項目名稱:Behat-Laravel-Extension,代碼行數:13,代碼來源:BehatExtension.php

示例2: loadInitializer

 /**
  * Load the initializer.
  *
  * @param ContainerBuilder $container
  * @param \Illuminate\Container\Container $app
  */
 private function loadInitializer(ContainerBuilder $container, $app)
 {
     $definition = new Definition('Arisro\\Behat\\Context\\ApplicationAwareInitializer', [$app]);
     $definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG, ['priority' => 0]);
     $definition->addTag(ContextExtension::INITIALIZER_TAG, ['priority' => 0]);
     $container->setDefinition('lumen.initializer', $definition);
 }
開發者ID:arisro,項目名稱:behat-lumen-extension,代碼行數:13,代碼來源:LumenExtension.php

示例3: addResourceListeners

 /**
  * @param ContainerBuilder $container
  * @param MetadataInterface $metadata
  */
 protected function addResourceListeners(ContainerBuilder $container, MetadataInterface $metadata)
 {
     $defaultOptions = ['parent_path_default' => null, 'parent_path_autocreate' => false, 'parent_path_force' => false, 'name_filter' => true, 'name_resolver' => true];
     $metadataOptions = $metadata->hasParameter('options') ? $metadata->getParameter('options') : [];
     if ($diff = array_diff(array_keys($metadataOptions), array_keys($defaultOptions))) {
         throw new InvalidArgumentException(sprintf('Unknown PHPCR-ODM configuration options: "%s"', implode('", "', $diff)));
     }
     $options = array_merge($defaultOptions, $metadataOptions);
     $createEventName = sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), 'create');
     $updateEventName = sprintf('%s.%s.pre_%s', $metadata->getApplicationName(), $metadata->getName(), 'update');
     if ($options['parent_path_default']) {
         $defaultPath = new Definition(DefaultParentListener::class);
         $defaultPath->setArguments([new Reference($metadata->getServiceId('manager')), $options['parent_path_default'], $options['parent_path_autocreate'], $options['parent_path_force']]);
         $defaultPath->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onPreCreate']);
         $container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.default_path', $metadata->getApplicationName(), $metadata->getName()), $defaultPath);
     }
     if ($options['name_filter']) {
         $nameFilter = new Definition(NameFilterListener::class);
         $nameFilter->setArguments([new Reference($metadata->getServiceId('manager'))]);
         $nameFilter->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onEvent']);
         $nameFilter->addTag('kernel.event_listener', ['event' => $updateEventName, 'method' => 'onEvent']);
         $container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.name_filter', $metadata->getApplicationName(), $metadata->getName()), $nameFilter);
     }
     if ($options['name_resolver']) {
         $nameResolver = new Definition(NameResolverListener::class);
         $nameResolver->setArguments([new Reference($metadata->getServiceId('manager'))]);
         $nameResolver->addTag('kernel.event_listener', ['event' => $createEventName, 'method' => 'onEvent']);
         $nameResolver->addTag('kernel.event_listener', ['event' => $updateEventName, 'method' => 'onEvent']);
         $container->setDefinition(sprintf('%s.resource.%s.doctrine.odm.phpcr.event_listener.name_resolver', $metadata->getApplicationName(), $metadata->getName()), $nameResolver);
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:35,代碼來源:DoctrinePHPCRDriver.php

示例4: loadConfigs

 /**
  * Process the adaptor config configuration.
  *
  * @param array $config
  * @param ContainerBuilder $container
  */
 protected function loadConfigs(array $config, ContainerBuilder $container)
 {
     foreach ($config['configs'] as $name => $arguments) {
         if (!$arguments['enabled']) {
             continue;
         }
         $id = 'integrated_channel.config.memory.' . $name;
         if ($container->hasDefinition($id)) {
             continue;
         }
         // first create the options and for that we need a unique service id
         do {
             $id_options = $id . '.options.' . uniqid();
         } while ($container->hasDefinition($id_options));
         $definition = new Definition('%integrated_channel.config.options.class%');
         $definition->setPublic(false);
         $definition->setArguments([$arguments['options']]);
         $container->setDefinition($id_options, $definition);
         // create the config it self
         $definition = new Definition('%integrated_channel.config.class%');
         $definition->setArguments([$name, $arguments['adaptor'], new Reference($id_options)]);
         if ($arguments['channel']) {
             foreach ($arguments['channel'] as $channel) {
                 $definition->addTag('integrated_channel.config', ['channel' => $channel]);
             }
         } else {
             $definition->addTag('integrated_channel.config');
         }
         $container->setDefinition($id, $definition);
     }
 }
開發者ID:integratedfordevelopers,項目名稱:integrated-channel-bundle,代碼行數:37,代碼來源:IntegratedChannelExtension.php

示例5: getElement

 private function getElement()
 {
     $service = new Definition();
     $service->setClass('stdClass');
     $service->setArguments(array(new Reference('arg.one'), new Reference('arg.two', ContainerInterface::IGNORE_ON_INVALID_REFERENCE), new Reference('arg.three', ContainerInterface::NULL_ON_INVALID_REFERENCE), '@arg.four'));
     $service->addTag('tag.one');
     $service->addTag('tag.two', array('attr' => 'one'));
     $service->addTag('tag.two', array('attr' => 'two'));
     return new ServiceElement('service.one', $service);
 }
開發者ID:vierbergenlars,項目名稱:manipulator-bundle,代碼行數:10,代碼來源:ServiceElementTest.php

示例6: it_adds_translation_loaders_using_only_the_first_tag_alias

 /**
  * @test
  */
 public function it_adds_translation_loaders_using_only_the_first_tag_alias()
 {
     $this->setDefinition('sylius.theme.translation.loader_provider', new Definition(null, [[]]));
     $translationLoaderDefinition = new Definition();
     $translationLoaderDefinition->addTag('translation.loader', ['alias' => 'yml']);
     $translationLoaderDefinition->addTag('translation.loader', ['alias' => 'yaml']);
     $this->setDefinition('translation.loader.yml', $translationLoaderDefinition);
     $this->compile();
     $this->assertContainerBuilderHasServiceDefinitionWithArgument('sylius.theme.translation.loader_provider', 0, ['yml' => new Reference('translation.loader.yml')]);
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:13,代碼來源:TranslatorLoaderProviderPassTest.php

示例7: load

 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $container->setParameter('lexiphanic_encrypted_cookie.cookies', $config['cookies']);
     $container->setParameter('lexiphanic_encrypted_cookie.encryption.service', $config['encryption']['service']);
     $listener = new Definition('Lexiphanic\\EncryptedCookieBundle\\EventListener\\EncryptedCookieListener', ['%lexiphanic_encrypted_cookie.cookies%', new Reference($config['encryption']['service'])]);
     $listener->addTag('kernel.event_listener', ['event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => 8192]);
     $listener->addTag('kernel.event_listener', ['event' => 'kernel.response', 'method' => 'onKernelResponse', 'priority' => -8192]);
     $container->setDefinition('lexiphanic.encrypted_cookie_listener', $listener);
 }
開發者ID:lexiphanic,項目名稱:encrypted-cookie-bundle,代碼行數:14,代碼來源:LexiphanicEncryptedCookieExtension.php

示例8: createConnectionListener

 /**
  * @param ContainerBuilder $container
  * @param string           $connection
  * @param string           $defaultConnection
  */
 private function createConnectionListener(ContainerBuilder $container, $connection, string $defaultConnection)
 {
     $listenerArguments = [$connection, $connection === $defaultConnection, new Reference('algatux_influx_db.connection.' . $connection . '.http')];
     if ($container->hasDefinition('algatux_influx_db.connection.' . $connection . '.udp')) {
         array_push($listenerArguments, new Reference('algatux_influx_db.connection.' . $connection . '.udp'));
     }
     $listenerDefinition = new Definition(InfluxDbEventListener::class, $listenerArguments);
     $listenerDefinition->addTag('kernel.event_listener', ['event' => 'influxdb.points_collected', 'method' => 'onPointsCollected']);
     $listenerDefinition->addTag('kernel.event_listener', ['event' => 'kernel.terminate', 'method' => 'onKernelTerminate']);
     $container->setDefinition('algatux_influx_db.event_listener.' . $connection, $listenerDefinition);
 }
開發者ID:Algatux,項目名稱:influxdb-bundle,代碼行數:16,代碼來源:InfluxDbExtension.php

示例9: addContainerScopeListener

 /**
  * Adds the container scope listener.
  *
  * @param ContainerBuilder $container
  */
 private function addContainerScopeListener(ContainerBuilder $container)
 {
     if (!method_exists('Symfony\\Component\\DependencyInjection\\Container', 'enterScope')) {
         return;
     }
     $definition = new Definition('Contao\\CoreBundle\\EventListener\\ContainerScopeListener');
     $definition->addArgument(new Reference('service_container'));
     $definition->addTag('kernel.event_listener', ['event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => 30]);
     $definition->addTag('kernel.event_listener', ['event' => 'kernel.finish_request', 'method' => 'onKernelFinishRequest', 'priority' => -254]);
     $container->setDefinition('contao.listener.container_scope', $definition);
 }
開發者ID:contao,項目名稱:core-bundle,代碼行數:16,代碼來源:ContaoCoreExtension.php

示例10: definitionProvider

 public function definitionProvider()
 {
     $definitionWithoutTags = new Definition();
     $definitionWithTwoTags = new Definition();
     $tag = 'some_provider';
     $attributesOfFirstTag = array('name' => 'attribute of first tag');
     $definitionWithTwoTags->addTag($tag, $attributesOfFirstTag);
     $attributesOfSecondTag = array('name' => 'attributes of second tag');
     $definitionWithTwoTags->addTag($tag, $attributesOfSecondTag);
     $otherAttributes = array('name' => 'some other attribute');
     return array(array($definitionWithoutTags, $tag, array(), false), array($definitionWithTwoTags, $tag, $attributesOfFirstTag, true), array($definitionWithTwoTags, $tag, $attributesOfSecondTag, true), array($definitionWithTwoTags, $tag, $otherAttributes, false));
 }
開發者ID:kinkinweb,項目名稱:lhvb,代碼行數:12,代碼來源:DefinitionHasTagConstraintTest.php

示例11: testAddResolver

 /**
  * @param int|null $declaredPriority
  * @param int $expectedPriority
  *
  * @covers eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\ChainConfigResolverPass::process
  * @dataProvider addResolverProvider
  */
 public function testAddResolver($declaredPriority, $expectedPriority)
 {
     $resolverDef = new Definition();
     $serviceId = 'some_service_id';
     if ($declaredPriority !== null) {
         $resolverDef->addTag('ezpublish.config.resolver', array('priority' => $declaredPriority));
     } else {
         $resolverDef->addTag('ezpublish.config.resolver');
     }
     $this->setDefinition($serviceId, $resolverDef);
     $this->compile();
     $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('ezpublish.config.resolver.chain', 'addResolver', array(new Reference($serviceId), $expectedPriority));
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:20,代碼來源:ChainConfigResolverPassTest.php

示例12: testAddViewProvider

 /**
  * @dataProvider addViewProviderProvider
  */
 public function testAddViewProvider($declaredPriority, $expectedPriority)
 {
     $def = new Definition();
     if ($declaredPriority !== null) {
         $def->addTag(BlockViewPass::VIEW_PROVIDER_IDENTIFIER, array('priority' => $declaredPriority));
     } else {
         $def->addTag(BlockViewPass::VIEW_PROVIDER_IDENTIFIER);
     }
     $serviceId = 'service_id';
     $this->setDefinition($serviceId, $def);
     $this->compile();
     $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('ezpublish.view_manager', BlockViewPass::ADD_VIEW_PROVIDER_METHOD, array(new Reference($serviceId), $expectedPriority));
 }
開發者ID:brookinsconsulting,項目名稱:ezecosystem,代碼行數:16,代碼來源:BlockViewPassTest.php

示例13: load

 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     foreach ($config['zones'] as $rule => $zoneOptions) {
         $zoneLoggerDefinition = new Definition('Vesax\\HttpKernelLoggerBundle\\EventListener\\TerminateListener', [new Reference('logger'), new Reference('vesax.http_kernel_logger.formatter'), '|' . $rule . '|']);
         $zoneLoggerDefinition->addTag('kernel.event_subscriber');
         $zoneLoggerDefinition->addTag('monolog.logger', ['channel' => $zoneOptions['channel']]);
         $container->setDefinition('vesax.http_kernel_logger.loggers.' . md5($rule), $zoneLoggerDefinition);
     }
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
 }
開發者ID:vesax,項目名稱:http-kernel-logger-bundle,代碼行數:16,代碼來源:VesaxHttpKernelLoggerExtension.php

示例14: testAddLocationAndContentHandlers

 public function testAddLocationAndContentHandlers()
 {
     $this->setDefinition('ezpublish.persistence.legacy.search.gateway.criteria_converter.content', new Definition());
     $this->setDefinition('ezpublish.persistence.legacy.search.gateway.criteria_converter.location', new Definition());
     $commonServiceId = 'common_service_id';
     $def = new Definition();
     $def->addTag('ezpublish.persistence.legacy.search.gateway.criterion_handler.content');
     $def->addTag('ezpublish.persistence.legacy.search.gateway.criterion_handler.location');
     $this->setDefinition($commonServiceId, $def);
     $this->compile();
     $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('ezpublish.persistence.legacy.search.gateway.criteria_converter.content', 'addHandler', array(new Reference($commonServiceId)));
     $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('ezpublish.persistence.legacy.search.gateway.criteria_converter.location', 'addHandler', array(new Reference($commonServiceId)));
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:13,代碼來源:CriteriaConverterPassTest.php

示例15: addFormType

 protected function addFormType(array $config, ContainerBuilder $container, $method)
 {
     $fullMethod = 'multisafepay_' . $method;
     $definition = new Definition();
     $definition->setClass('%ruudk_payment_multisafepay.form.default_type.class%');
     $definition->addArgument($fullMethod);
     if ($method === 'ideal') {
         $definition->setClass('%ruudk_payment_multisafepay.form.ideal_type.class%');
         $definition->addArgument(sprintf('%%ruudk_payment_multisafepay.ideal.issuers.%s%%', $config['test'] ? 'test' : 'live'));
     }
     $definition->addTag('payment.method_form_type');
     $definition->addTag('form.type', array('alias' => $fullMethod));
     $container->setDefinition(sprintf('ruudk_payment_multisafepay.form.%s_type', $method), $definition);
 }
開發者ID:ruudk,項目名稱:payment-multisafepay-bundle,代碼行數:14,代碼來源:RuudkPaymentMultisafepayExtension.php


注:本文中的Symfony\Component\DependencyInjection\Definition::addTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。