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


PHP ContainerBuilder::addAliases方法代碼示例

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


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

示例1: process

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $config = $container->getParameter(ModeraActivityLoggerExtension::CONFIG_KEY);
     $aliasConfig = array();
     // alias : id
     $aliasConfig['modera_activity_logger.manager.activity_manager'] = $config['activity_manager'];
     $container->addAliases($aliasConfig);
 }
開發者ID:modera,項目名稱:foundation,代碼行數:11,代碼來源:ServiceAliasCompilerPass.php

示例2: process

 public function process(ContainerBuilder $container)
 {
     if (false === $container->hasParameter('francodacosta.caparica.client.provider.id')) {
         throw new InvalidConfigurationException("[Caparica] Missing client provider id");
     }
     $providerId = $container->getParameter('francodacosta.caparica.client.provider.id');
     $container->addAliases(['francodacosta.caparica.client.provider' => $providerId]);
 }
開發者ID:francodacosta,項目名稱:caparica-bundle,代碼行數:8,代碼來源:ClientProviderPass.php

示例3: process

 /**
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $appDefinition = $container->register('proto_kernel.app', Application::class);
     $arguments = [null, null];
     if ($container->hasParameter('app.name')) {
         $arguments[0] = '%app.name%';
     }
     if ($container->hasParameter('app.version')) {
         $arguments[1] = '%app.version%';
     }
     $appDefinition->setArguments($arguments);
     $container->addAliases(['app' => 'proto_kernel.app']);
 }
開發者ID:protobile,項目名稱:framework,代碼行數:16,代碼來源:RegisterApplicationPass.php

示例4: load

 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $config = $this->processConfiguration(new Configuration(), $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $container->setAlias('kassko_class_resolver', new Alias('kassko_class_resolver.chain', true));
     $containerAdapterDef = $container->getDefinition('kassko_class_resolver.container');
     $containerAdapterDef->setClass($config['container_adapter_class']);
     $container->addAliases($config['resolvers_aliases']);
     if (isset($config['resolvers'])) {
         foreach ($config['resolvers']['chain'] as $resolverConfig) {
             $resolverDef = new DefinitionDecorator('kassko_class_resolver.chain');
             foreach ($resolverConfig['nested_resolvers'] as $nestedResolverService) {
                 $resolverDef->addMethodCall('add', [new Reference($nestedResolverService)]);
             }
             if (null !== $resolverConfig['service']) {
                 $resolverDef->addMethodCall('setDefault', [new Reference($resolverConfig['service'])]);
             } else {
                 $defaultResolverDef = new Definition($container->getParameter('kassko_class_resolver.default.class'), ['action' => $resolverConfig['on_not_found_class']['action']]);
                 $resolverDef->addMethodCall('setDefault', [$defaultResolverDef]);
             }
             $this->addAliasesByService($container, $config['resolver_aliases'], $resolverConfig['resolver_service']);
         }
         foreach ($config['resolvers']['container'] as $resolverConfig) {
             $container->setDefinition($resolverConfig['resolver_service'], new DefinitionDecorator('kassko_class_resolver.container_aware'));
             $this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
         }
         foreach ($config['resolvers']['map'] as $resolverConfig) {
             foreach ($resolverConfig['items'] as $item) {
                 if ('@' !== substr($item['service'], 0, 1)) {
                     $item['service'] = new Reference($item['service']);
                 }
             }
             $resolverDef = new Definition($container->getParameter('kassko_class_resolver.map.class'), [$resolverConfig['items']]);
             $container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
             $this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
         }
         foreach ($config['resolvers']['factory_adapter'] as $index => $resolverConfig) {
             $resolverDef = new Definition($container->getParameter('kassko_class_resolver.factory_adapter.class'), [new Reference($resolverConfig['adapted_factory']), $resolverConfig['support_method'], $resolverConfig['resolve_method']]);
             $container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
             $this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
         }
         foreach ($config['resolvers']['static_factory_adapter'] as $index => $resolverConfig) {
             $resolverDef = new Definition($container->getParameter('kassko_class_resolver.static_factory_adapter.class'), [$resolverConfig['adapted_factory'], $resolverConfig['support_method'], $resolverConfig['resolve_method']]);
             $container->setDefinition($resolverConfig['resolver_service'], $resolverDef);
             $this->addAliasesByService($container, $resolverConfig['resolver_aliases'], $resolverConfig['resolver_service']);
         }
     }
 }
開發者ID:kassko,項目名稱:class-resolver-bundle,代碼行數:52,代碼來源:KasskoClassResolverExtension.php

示例5: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     foreach ($container->getExtensions() as $name => $extension) {
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->addObjectResource($extension);
         $extension->load($container->getExtensionConfig($name), $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
開發者ID:noelg,項目名稱:symfony-demo,代碼行數:18,代碼來源:MergeExtensionConfigurationPass.php

示例6: load

 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $config = $this->processConfiguration(new Configuration(), $configs);
     $container->setParameter('pheat.manager.class', $config['manager']['class']);
     $container->setParameter('pheat.context.class', $config['context']['class']);
     $container->addAliases(['pheat.context' => $config['context']['service']]);
     if (!empty($config['providers']['session'])) {
         $loader->load('session.xml');
     }
     if (!empty($config['providers']['config'])) {
         $loader->load('config.xml');
         $container->getDefinition('pheat.provider.config')->setArguments([$config['features']]);
     }
     $loader->load('services.xml');
 }
開發者ID:letchik,項目名稱:VendPheatBundle,代碼行數:16,代碼來源:VendPheatExtension.php

示例7: configureOptions

 /**
  * Configure optional settings
  *
  * @param $config
  * @param ContainerBuilder $container
  */
 protected function configureOptions(&$config, ContainerBuilder $container)
 {
     if ($config['enable_logging'] !== true) {
         Logger::set(new NullLogger());
     }
     if (isset($config['router']['authentication']) && $config['router']['authentication'] !== false) {
         //Inject the authentication manager into the router
         $container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.authentication.manager')]);
     }
     if ($container->hasDefinition('security.user.provider.concrete.in_memory')) {
         $container->addAliases(['in_memory_user_provider' => 'security.user.provider.concrete.in_memory']);
     }
     //Topic State Handler
     if (isset($config['router']['enable_topic_state']) && $config['router']['enable_topic_state'] === true) {
         $container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.topic.state.handler')]);
     }
 }
開發者ID:haroldmodesto,項目名稱:ThruwayBundle,代碼行數:23,代碼來源:VoryxThruwayExtension.php

示例8: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     foreach ($container->getExtensionConfigs() as $name => $configs) {
         list($namespace, $tag) = explode(':', $name);
         $extension = $container->getExtension($namespace);
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->addObjectResource($extension);
         $extension->load($tag, $configs, $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
開發者ID:faridos,項目名稱:ServerGroveLiveChat,代碼行數:20,代碼來源:MergeExtensionConfigurationPass.php

示例9: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     $parameters = $container->getParameterBag()->all();
     $definitions = $container->getDefinitions();
     $aliases = $container->getAliases();
     foreach ($container->getExtensions() as $name => $extension) {
         if (!($config = $container->getExtensionConfig($name))) {
             // this extension was not called
             continue;
         }
         $config = $container->getParameterBag()->resolveValue($config);
         $tmpContainer = new ContainerBuilder($container->getParameterBag());
         $tmpContainer->addObjectResource($extension);
         $extension->load($config, $tmpContainer);
         $container->merge($tmpContainer);
     }
     $container->addDefinitions($definitions);
     $container->addAliases($aliases);
     $container->getParameterBag()->add($parameters);
 }
開發者ID:artz20,項目名稱:Tv-shows-zone,代碼行數:23,代碼來源:MergeExtensionConfigurationPass.php

示例10: configureOptions

 /**
  * Configure optional settings
  *
  * @param $config
  * @param ContainerBuilder $container
  */
 protected function configureOptions(&$config, ContainerBuilder $container)
 {
     //Add optional Manager
     if (isset($config['router']['enable_manager']) && $config['router']['enable_manager'] === true) {
         //Replace the dummy manager with the client manager
         $container->getDefinition('voryx.thruway.manager.client')->setClass('Thruway\\Manager\\ManagerClient');
         //Inject the manager client into the router
         $container->getDefinition('voryx.thruway.server')->addMethodCall('addTransportProvider', [new Reference('voryx.thruway.internal.manager')]);
     }
     if ($config['enable_logging'] !== true) {
         Logger::set(new NullLogger());
     }
     if (isset($config['router']['authentication']) && $config['router']['authentication'] !== false) {
         //Inject the authentication manager into the router
         $container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.authentication.manager')]);
     }
     if ($container->hasDefinition('security.user.provider.concrete.in_memory')) {
         $container->addAliases(['in_memory_user_provider' => 'security.user.provider.concrete.in_memory']);
     }
     //Topic State Handler
     if (isset($config['router']['enable_topic_state']) && $config['router']['enable_topic_state'] === true) {
         $container->getDefinition('voryx.thruway.server')->addMethodCall('registerModule', [new Reference('voryx.thruway.topic.state.handler')]);
     }
 }
開發者ID:ThatCheck,項目名稱:ThruwayBundle,代碼行數:30,代碼來源:VoryxThruwayExtension.php

示例11: testAddAliases

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
  */
 public function testAddAliases()
 {
     $builder = new ContainerBuilder();
     $builder->setAliases(array('bar' => 'foo'));
     $builder->addAliases(array('foobar' => 'foo'));
     $aliases = $builder->getAliases();
     $this->assertTrue(isset($aliases['bar']));
     $this->assertTrue(isset($aliases['foobar']));
 }
開發者ID:tejdeeps,項目名稱:tejcs.com,代碼行數:12,代碼來源:ContainerBuilderTest.php

示例12: addAliases

 public function addAliases(array $aliases)
 {
     return $this->delegate->addAliases($aliases);
 }
開發者ID:planetenkiller,項目名稱:core,代碼行數:4,代碼來源:SandboxContainerBuilder.php

示例13: testAddAliases

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addAliases
  */
 public function testAddAliases()
 {
     $builder = new ContainerBuilder();
     $builder->setAliases(array('bar' => 'foo'));
     $builder->addAliases(array('foobar' => 'foo'));
     $this->assertEquals(array('bar' => 'foo', 'foobar' => 'foo'), $builder->getAliases(), '->getAliases() returns all service aliases');
 }
開發者ID:netixpro,項目名稱:symfony,代碼行數:10,代碼來源:ContainerBuilderTest.php


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