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


PHP Definition::setTags方法代码示例

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


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

示例1: registerAuthenticationListener

 /**
  * If authorization is enabled authentication listener is registered.
  *
  * @param array            $config
  * @param ContainerBuilder $container
  */
 private function registerAuthenticationListener(array $config, ContainerBuilder $container)
 {
     if ($config['authorization']['enabled']) {
         $definition = new Definition($container->getParameter('ongr_api.event_listener.authentication.class'), [new Reference('service_container'), $config['authorization']['secret']]);
         $definition->setTags(['kernel.event_listener' => [['event' => 'kernel.request', 'method' => 'onKernelRequest', 'priority' => 10]]]);
         $container->setDefinition('ongr_api.event_listener.authentication', $definition);
     }
 }
开发者ID:vinhdrt,项目名称:ApiBundle,代码行数:14,代码来源:ONGRApiExtension.php

示例2: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = $this->getConfiguration($configs, $container);
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     if (array_key_exists('SensioFrameworkExtraBundle', $container->getParameter('kernel.bundles'))) {
         $definition = new Definition(JsonApiParamConverter::class, [new Reference('qp_woohoolabs_yin.json_api.factory')]);
         $definition->setTags(['request.param_converter' => [[]]]);
         $container->setDefinition('qp_woohoolabs_yin.json_api.param_converter', $definition);
     }
     $container->setAlias('qp_woohoolabs_yin.exception_factory', $config['exception_factory']);
 }
开发者ID:qpautrat,项目名称:woohoolabs-yin-bundle,代码行数:13,代码来源:QPWoohoolabsYinExtension.php

示例3: swapServiceWithProxy

 /**
  * @param ContainerBuilder $container
  * @param string           $service
  */
 private function swapServiceWithProxy(ContainerBuilder $container, string $service)
 {
     $instanceId = sprintf('phpro.annotated_cache.eligable_instance.%s', sha1($service));
     $instance = $container->findDefinition($service);
     $instance->setPublic(false);
     $proxy = new Definition(AccessInterceptorInterface::class);
     $proxy->setFactory([new Reference('phpro.annotation_cache.proxy.generator'), 'generate']);
     $proxy->setArguments([new Reference($instanceId)]);
     // Make sure that the proxy gets all instance tags:
     $proxy->setTags($instance->getTags());
     $instance->clearTags();
     $container->setDefinition($instanceId, $instance);
     $container->setDefinition($service, $proxy);
 }
开发者ID:phpro,项目名称:annotated-cache-bundle,代码行数:18,代码来源:CacheEligableCompilerPass.php

示例4: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     $queueManagers = [];
     foreach ($config['managers'] as $name => $manager) {
         if (!isset($config['drivers'][$manager['driver']])) {
             throw new InvalidArgumentException("Manager '{$name}' uses unknown driver '{$manager['driver']}'");
         }
         $managerClass = $config['drivers'][$manager['driver']]['class'];
         $defaultOptions = isset($config['drivers'][$manager['driver']]['options']) ? $config['drivers'][$manager['driver']]['options'] : [];
         $options = isset($manager['options']) ? $manager['options'] : [];
         $merged = array_merge(['debug' => $config['debug'], 'retry_limit' => $config['retry_limit'], 'sleep_seconds' => $config['sleep_seconds']], $defaultOptions, $options);
         $container->setParameter("mcfedr_queue_manager.{$name}.options", $merged);
         $managerServiceName = "mcfedr_queue_manager.{$name}";
         $managerDefinition = new Definition($managerClass, [$merged]);
         if ((new \ReflectionClass($managerClass))->implementsInterface(ContainerAwareInterface::class)) {
             $managerDefinition->addMethodCall('setContainer', [new Reference('service_container')]);
         }
         $container->setDefinition($managerServiceName, $managerDefinition);
         $queueManagers[$name] = new Reference($managerServiceName);
         if (isset($config['drivers'][$manager['driver']]['command_class'])) {
             $commandClass = $config['drivers'][$manager['driver']]['command_class'];
             $commandDefinition = new Definition($commandClass, ["mcfedr:queue:{$name}-runner", $merged, new Reference($managerServiceName)]);
             $commandDefinition->setTags(['console.command' => []]);
             $container->setDefinition("mcfedr_queue_manager.runner.{$name}", $commandDefinition);
         }
     }
     if (array_key_exists('default', $queueManagers)) {
         $defaultManager = 'default';
     } else {
         reset($queueManagers);
         $defaultManager = key($queueManagers);
     }
     $container->setDefinition('mcfedr_queue_manager.registry', new Definition(QueueManagerRegistry::class, [$queueManagers, $defaultManager]));
     if ($config['report_memory']) {
         $mem = new Definition(MemoryReportSubscriber::class, [new Reference('logger')]);
         $mem->setTags(['kernel.event_subscriber' => []]);
         $container->setDefinition('mcfedr_queue_manager.memory_report_subscriber', $mem);
     }
     if ($config['doctrine_reset']) {
         $mem = new Definition(DoctrineResetSubscriber::class, [new Reference('doctrine', ContainerInterface::NULL_ON_INVALID_REFERENCE)]);
         $mem->setTags(['kernel.event_subscriber' => []]);
         $container->setDefinition('mcfedr_queue_manager.doctrine_reset_subscriber', $mem);
     }
 }
开发者ID:mcfedr,项目名称:queue-manager-bundle,代码行数:51,代码来源:McfedrQueueManagerExtension.php

示例5: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $definitions = $container->findTaggedServiceIds('ongr_settings.setting_aware');
     foreach ($definitions as $serviceId => $tags) {
         $definition = $container->getDefinition($serviceId);
         $initialTags = $definition->getTags();
         $definition->clearTags();
         $container->setDefinition("{$serviceId}_base", $definition);
         $callMap = [];
         foreach ($tags as $tag) {
             $callMap[$tag['setting']] = isset($tag['method']) ? $tag['method'] : null;
         }
         $proxy = new Definition($definition->getClass(), [$callMap, new Reference("{$serviceId}_base")]);
         $proxy->setFactoryService('ongr_settings.setting_aware_service_factory');
         $proxy->setFactoryMethod('get');
         unset($initialTags['ongr_settings.setting_aware']);
         $proxy->setTags($initialTags);
         $container->setDefinition($serviceId, $proxy);
     }
 }
开发者ID:asev,项目名称:SettingsBundle,代码行数:23,代码来源:SettingAwareFactoryPass.php

示例6: prependElasticaProductListener

 /**
  * @param ContainerBuilder $container
  */
 private function prependElasticaProductListener(ContainerBuilder $container)
 {
     if (!$container->hasExtension('fos_elastica') || !$container->hasExtension('sylius_search')) {
         return;
     }
     $configuration = new SyliusSearchConfiguration();
     $processor = new Processor();
     $syliusSearchConfig = $processor->processConfiguration($configuration, $container->getExtensionConfig('sylius_search'));
     $engine = $syliusSearchConfig['engine'];
     if ($engine === 'elasticsearch') {
         $tags = ['doctrine.event_listener' => [['name' => 'doctrine.event_listener', 'event' => 'postPersist'], ['name' => 'doctrine.event_listener', 'event' => 'postUpdate'], ['name' => 'doctrine.event_listener', 'event' => 'postRemove'], ['name' => 'doctrine.event_listener', 'event' => 'postFlush']]];
         $configuration = new FosElasticaConfiguration(false);
         $processor = new Processor();
         $elasticaConfig = $processor->processConfiguration($configuration, $container->getExtensionConfig('fos_elastica'));
         foreach ($elasticaConfig['indexes'] as $index => $config) {
             $elasticaProductListenerDefinition = new Definition(ElasticaProductListener::class);
             $elasticaProductListenerDefinition->addArgument(new Reference('fos_elastica.object_persister.' . $index . '.product'));
             $elasticaProductListenerDefinition->setTags($tags);
             $container->setDefinition('sylius_product.listener.index_' . $index . '.product_update', $elasticaProductListenerDefinition);
         }
     }
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:25,代码来源:SyliusSearchExtension.php

示例7: resolveDefinition


//.........这里部分代码省略.........
         $container->setDefinition($parent, $parentDef);
         $this->currentId = $id;
     }
     $this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $this->currentId, $parent));
     $def = new Definition();
     // merge in parent definition
     // purposely ignored attributes: scope, abstract, tags
     $def->setClass($parentDef->getClass());
     $def->setArguments($parentDef->getArguments());
     $def->setMethodCalls($parentDef->getMethodCalls());
     $def->setProperties($parentDef->getProperties());
     $def->setAutowiringTypes($parentDef->getAutowiringTypes());
     if ($parentDef->getFactoryClass(false)) {
         $def->setFactoryClass($parentDef->getFactoryClass(false));
     }
     if ($parentDef->getFactoryMethod(false)) {
         $def->setFactoryMethod($parentDef->getFactoryMethod(false));
     }
     if ($parentDef->getFactoryService(false)) {
         $def->setFactoryService($parentDef->getFactoryService(false));
     }
     if ($parentDef->isDeprecated()) {
         $def->setDeprecated(true, $parentDef->getDeprecationMessage('%service_id%'));
     }
     $def->setFactory($parentDef->getFactory());
     $def->setConfigurator($parentDef->getConfigurator());
     $def->setFile($parentDef->getFile());
     $def->setPublic($parentDef->isPublic());
     $def->setLazy($parentDef->isLazy());
     // overwrite with values specified in the decorator
     $changes = $definition->getChanges();
     if (isset($changes['class'])) {
         $def->setClass($definition->getClass());
     }
     if (isset($changes['factory_class'])) {
         $def->setFactoryClass($definition->getFactoryClass(false));
     }
     if (isset($changes['factory_method'])) {
         $def->setFactoryMethod($definition->getFactoryMethod(false));
     }
     if (isset($changes['factory_service'])) {
         $def->setFactoryService($definition->getFactoryService(false));
     }
     if (isset($changes['factory'])) {
         $def->setFactory($definition->getFactory());
     }
     if (isset($changes['configurator'])) {
         $def->setConfigurator($definition->getConfigurator());
     }
     if (isset($changes['file'])) {
         $def->setFile($definition->getFile());
     }
     if (isset($changes['public'])) {
         $def->setPublic($definition->isPublic());
     }
     if (isset($changes['lazy'])) {
         $def->setLazy($definition->isLazy());
     }
     if (isset($changes['deprecated'])) {
         $def->setDeprecated($definition->isDeprecated(), $definition->getDeprecationMessage('%service_id%'));
     }
     if (isset($changes['decorated_service'])) {
         $decoratedService = $definition->getDecoratedService();
         if (null === $decoratedService) {
             $def->setDecoratedService($decoratedService);
         } else {
             $def->setDecoratedService($decoratedService[0], $decoratedService[1], $decoratedService[2]);
         }
     }
     // merge arguments
     foreach ($definition->getArguments() as $k => $v) {
         if (is_numeric($k)) {
             $def->addArgument($v);
             continue;
         }
         if (0 !== strpos($k, 'index_')) {
             throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
         }
         $index = (int) substr($k, strlen('index_'));
         $def->replaceArgument($index, $v);
     }
     // merge properties
     foreach ($definition->getProperties() as $k => $v) {
         $def->setProperty($k, $v);
     }
     // append method calls
     if (count($calls = $definition->getMethodCalls()) > 0) {
         $def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
     }
     // merge autowiring types
     foreach ($definition->getAutowiringTypes() as $autowiringType) {
         $def->addAutowiringType($autowiringType);
     }
     // these attributes are always taken from the child
     $def->setAbstract($definition->isAbstract());
     $def->setScope($definition->getScope(false), false);
     $def->setShared($definition->isShared());
     $def->setTags($definition->getTags());
     return $def;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:ResolveDefinitionTemplatesPass.php

示例8: resolveDefinition

 /**
  * Resolves the definition
  *
  * @param string              $id         The definition identifier
  * @param DefinitionDecorator $definition
  *
  * @return Definition
  */
 private function resolveDefinition($id, DefinitionDecorator $definition)
 {
     if (!$this->container->hasDefinition($parent = $definition->getParent())) {
         throw new RuntimeException(sprintf('The parent definition "%s" defined for definition "%s" does not exist.', $parent, $id));
     }
     $parentDef = $this->container->getDefinition($parent);
     if ($parentDef instanceof DefinitionDecorator) {
         $parentDef = $this->resolveDefinition($parent, $parentDef);
     }
     $this->compiler->addLogMessage($this->formatter->formatResolveInheritance($this, $id, $parent));
     $def = new Definition();
     // merge in parent definition
     // purposely ignored attributes: scope, abstract, tags
     $def->setClass($parentDef->getClass());
     $def->setArguments($parentDef->getArguments());
     $def->setMethodCalls($parentDef->getMethodCalls());
     $def->setProperties($parentDef->getProperties());
     $def->setFactoryClass($parentDef->getFactoryClass());
     $def->setFactoryMethod($parentDef->getFactoryMethod());
     $def->setFactoryService($parentDef->getFactoryService());
     $def->setConfigurator($parentDef->getConfigurator());
     $def->setFile($parentDef->getFile());
     $def->setPublic($parentDef->isPublic());
     // overwrite with values specified in the decorator
     $changes = $definition->getChanges();
     if (isset($changes['class'])) {
         $def->setClass($definition->getClass());
     }
     if (isset($changes['factory_class'])) {
         $def->setFactoryClass($definition->getFactoryClass());
     }
     if (isset($changes['factory_method'])) {
         $def->setFactoryMethod($definition->getFactoryMethod());
     }
     if (isset($changes['factory_service'])) {
         $def->setFactoryService($definition->getFactoryService());
     }
     if (isset($changes['configurator'])) {
         $def->setConfigurator($definition->getConfigurator());
     }
     if (isset($changes['file'])) {
         $def->setFile($definition->getFile());
     }
     if (isset($changes['public'])) {
         $def->setPublic($definition->isPublic());
     }
     // merge arguments
     foreach ($definition->getArguments() as $k => $v) {
         if (is_numeric($k)) {
             $def->addArgument($v);
             continue;
         }
         if (0 !== strpos($k, 'index_')) {
             throw new RuntimeException(sprintf('Invalid argument key "%s" found.', $k));
         }
         $index = (int) substr($k, strlen('index_'));
         $def->replaceArgument($index, $v);
     }
     // merge properties
     foreach ($definition->getProperties() as $k => $v) {
         $def->setProperty($k, $v);
     }
     // append method calls
     if (count($calls = $definition->getMethodCalls()) > 0) {
         $def->setMethodCalls(array_merge($def->getMethodCalls(), $calls));
     }
     // these attributes are always taken from the child
     $def->setAbstract($definition->isAbstract());
     $def->setScope($definition->getScope());
     $def->setTags($definition->getTags());
     // set new definition on container
     $this->container->setDefinition($id, $def);
     return $def;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:82,代码来源:ResolveDefinitionTemplatesPass.php

示例9: getTaggedService

 /**
  * @param string $tag
  * @param array  $attributes
  * @param string $className
  * @param array  $arguments
  *
  * @return Definition
  */
 private function getTaggedService($tag, array $attributes = [], $className = \stdClass::class, $arguments = [])
 {
     $definition = new Definition($className, $arguments);
     $definition->setTags([$tag => [$attributes]]);
     return $definition;
 }
开发者ID:skolodyazhnyy,项目名称:service-bus-bundle,代码行数:14,代码来源:ServiceBindingPassTest.php

示例10: setTags

 /**
  * Set tags for this definition
  *
  * @param array $tags
  *
  * @return tubepress_api_ioc_DefinitionInterface the current instance
  *
  * @api
  * @since 4.0.0
  */
 public function setTags(array $tags)
 {
     $this->_underlyingSymfonyDefinition->setTags($tags);
     return $this;
 }
开发者ID:tubepress,项目名称:tubepress,代码行数:15,代码来源:Definition.php

示例11: createPsr7CompliantService

 /**
  * Make sure to create a PRS-6 service that wraps the doctrine service.
  *
  * @param ContainerBuilder $container
  * @param string           $doctrineServiceId
  * @param string           $name
  */
 protected function createPsr7CompliantService(ContainerBuilder $container, $doctrineServiceId, $name)
 {
     // This is the service id for the PSR6 provider. This is the one that we use.
     $serviceId = 'cache.doctrine_adapter.provider.' . $name;
     // Register the CacheItemPoolInterface definition
     $def = new Definition(DoctrineCachePool::class);
     $def->addArgument(new Reference($doctrineServiceId));
     $def->setTags(['cache.provider' => []]);
     $container->setDefinition($serviceId, $def);
     $container->setAlias('cache.provider.' . $name, $serviceId);
 }
开发者ID:php-cache,项目名称:doctrine-adapter-bundle,代码行数:18,代码来源:DoctrineAdapterExtension.php


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