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


PHP ContainerBuilder::setAliases方法代码示例

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


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

示例1: process

 /**
  * Processes the ContainerBuilder to resolve parameter placeholders.
  *
  * @param ContainerBuilder $container
  *
  * @throws ParameterNotFoundException
  */
 public function process(ContainerBuilder $container)
 {
     $parameterBag = $container->getParameterBag();
     foreach ($container->getDefinitions() as $id => $definition) {
         try {
             $definition->setClass($parameterBag->resolveValue($definition->getClass()));
             $definition->setFile($parameterBag->resolveValue($definition->getFile()));
             $definition->setArguments($parameterBag->resolveValue($definition->getArguments()));
             if ($definition->getFactoryClass(false)) {
                 $definition->setFactoryClass($parameterBag->resolveValue($definition->getFactoryClass(false)));
             }
             $factory = $definition->getFactory();
             if (is_array($factory) && isset($factory[0])) {
                 $factory[0] = $parameterBag->resolveValue($factory[0]);
                 $definition->setFactory($factory);
             }
             $calls = array();
             foreach ($definition->getMethodCalls() as $name => $arguments) {
                 $calls[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($arguments);
             }
             $definition->setMethodCalls($calls);
             $definition->setProperties($parameterBag->resolveValue($definition->getProperties()));
         } catch (ParameterNotFoundException $e) {
             $e->setSourceId($id);
             throw $e;
         }
     }
     $aliases = array();
     foreach ($container->getAliases() as $name => $target) {
         $aliases[$parameterBag->resolveValue($name)] = $parameterBag->resolveValue($target);
     }
     $container->setAliases($aliases);
     $parameterBag->resolve();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:41,代码来源:ResolveParameterPlaceHoldersPass.php

示例2: getContainerBuilders

 public static function getContainerBuilders()
 {
     $builder1 = new ContainerBuilder();
     $builder1->setDefinitions(self::getContainerDefinitions());
     $builder1->setAliases(self::getContainerAliases());
     return array('builder_1' => $builder1);
 }
开发者ID:tahermarkos,项目名称:Transport,代码行数:7,代码来源:ObjectsProvider.php

示例3: process

 public function process(ContainerBuilder $container)
 {
     $this->parameterBag = $container->getParameterBag();
     foreach ($container->getDefinitions() as $definition) {
         $definition->setClass($this->resolveValue($definition->getClass()));
         $definition->setFile($this->resolveValue($definition->getFile()));
         $definition->setArguments($this->resolveValue($definition->getArguments()));
         $calls = array();
         foreach ($definition->getMethodCalls() as $name => $arguments) {
             $calls[$this->resolveValue($name)] = $this->resolveValue($arguments);
         }
         $definition->setMethodCalls($calls);
     }
     $aliases = array();
     foreach ($container->getAliases() as $name => $target) {
         $aliases[$this->resolveValue($name)] = $this->resolveValue($target);
     }
     $container->setAliases($aliases);
     $injectors = array();
     foreach ($container->getInterfaceInjectors() as $class => $injector) {
         $injector->setClass($this->resolveValue($injector->getClass()));
         $injectors[$this->resolveValue($class)] = $injector;
     }
     $container->setInterfaceInjectors($injectors);
     $parameterBag = $container->getParameterBag();
     foreach ($parameterBag->all() as $key => $value) {
         $parameterBag->set($key, $this->resolveValue($value));
     }
 }
开发者ID:faridos,项目名称:ServerGroveLiveChat,代码行数:29,代码来源:ResolveParameterPlaceHoldersPass.php

示例4: process

 /**
  * Processes the ContainerBuilder to resolve parameter placeholders.
  *
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     $this->parameterBag = $container->getParameterBag();
     foreach ($container->getDefinitions() as $id => $definition) {
         try {
             $definition->setClass($this->resolveValue($definition->getClass()));
             $definition->setFile($this->resolveValue($definition->getFile()));
             $definition->setArguments($this->resolveValue($definition->getArguments()));
             $calls = array();
             foreach ($definition->getMethodCalls() as $name => $arguments) {
                 $calls[$this->resolveValue($name)] = $this->resolveValue($arguments);
             }
             $definition->setMethodCalls($calls);
             $definition->setProperties($this->resolveValue($definition->getProperties()));
         } catch (ParameterNotFoundException $e) {
             $e->setSourceId($id);
             throw $e;
         }
     }
     $aliases = array();
     foreach ($container->getAliases() as $name => $target) {
         $aliases[$this->resolveValue($name)] = $this->resolveValue($target);
     }
     $container->setAliases($aliases);
     $parameterBag = $container->getParameterBag();
     foreach ($parameterBag->all() as $key => $value) {
         try {
             $parameterBag->set($key, $this->resolveValue($value));
         } catch (ParameterNotFoundException $e) {
             $e->setSourceKey($key);
             throw $e;
         }
     }
 }
开发者ID:nuxwin,项目名称:i-PMS,代码行数:39,代码来源:ResolveParameterPlaceHoldersPass.php

示例5: 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

示例6: cloneContainer

 private function cloneContainer()
 {
     $parameterBag = new ParameterBag($this->container->getParameterBag()->all());
     $container = new ContainerBuilder($parameterBag);
     $container->setDefinitions($this->container->getDefinitions());
     $container->setAliases($this->container->getAliases());
     $container->setResources($this->container->getResources());
     foreach ($this->container->getExtensions() as $extension) {
         $container->registerExtension($extension);
     }
     return $container;
 }
开发者ID:xingshanghe,项目名称:symfony,代码行数:12,代码来源:GraphvizDumper.php

示例7: setAliases

 public function setAliases(array $aliases)
 {
     return $this->delegate->setAliases($aliases);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:4,代码来源:SandboxContainerBuilder.php

示例8: 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::setAliases方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。