當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。