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


PHP ContainerBuilder::getInterfaceInjectors方法代碼示例

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


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

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

示例2: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->getDefinitions() as $definition) {
         foreach ($container->getInterfaceInjectors() as $injector) {
             if (null !== $definition->getFactoryService()) {
                 continue;
             }
             $defClass = $container->getParameterBag()->resolveValue($definition->getClass());
             $definition->setClass($defClass);
             if ($injector->supports($defClass)) {
                 $injector->processDefinition($definition);
             }
         }
     }
 }
開發者ID:spf13,項目名稱:symfony,代碼行數:18,代碼來源:ResolveInterfaceInjectorsPass.php

示例3: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     foreach ($container->getDefinitions() as $definition) {
         $loaded = false;
         foreach ($container->getInterfaceInjectors() as $injector) {
             if (null !== $definition->getFactoryService()) {
                 continue;
             }
             if (false === $loaded && null !== $definition->getFile()) {
                 $loaded = true;
                 require_once $definition->getFile();
             }
             if ($injector->supports($definition->getClass())) {
                 $injector->processDefinition($definition);
             }
         }
     }
 }
開發者ID:rosstuck,項目名稱:Pok,代碼行數:21,代碼來源:ResolveInterfaceInjectorsPass.php

示例4: testLoadInterfaceInjectors

 public function testLoadInterfaceInjectors()
 {
     $container = new ContainerBuilder();
     $loader = new ProjectLoader3($container, self::$fixturesPath . '/yaml');
     $loader->load('interfaces1.yml');
     $interfaces = $container->getInterfaceInjectors('FooClass');
     $this->assertEquals(1, count($interfaces), '->load() parses interfaces');
     $interface = $interfaces['FooClass'];
     $this->assertTrue($interface->hasMethodCall('setBar'), '->load() parses interfaces elements');
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:10,代碼來源:YamlFileLoaderTest.php

示例5: testInterfaceInjection

 /**
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addInterfaceInjector
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::addInterfaceInjectors
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::getInterfaceInjectors
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::hasInterfaceInjectorForClass
  * @covers Symfony\Component\DependencyInjection\ContainerBuilder::setDefinition
  */
 public function testInterfaceInjection()
 {
     $definition = new Definition('Symfony\\Tests\\Component\\DependencyInjection\\FooClass');
     $injectors[] = $this->getMockInterfaceInjector('Symfony\\Tests\\Component\\DependencyInjection\\FooClass', 1);
     $injectors[] = $this->getMockInterfaceInjector('Symfony\\Tests\\Component\\DependencyInjection\\FooClass', 0);
     $container = new ContainerBuilder();
     $container->addInterfaceInjectors($injectors);
     $this->assertEquals(1, count($container->getInterfaceInjectors('Symfony\\Tests\\Component\\DependencyInjection\\FooClass')));
     $this->assertTrue($container->hasInterfaceInjectorForClass('Symfony\\Tests\\Component\\DependencyInjection\\FooClass'));
     $this->assertFalse($container->hasInterfaceInjectorForClass('\\Foo'));
     $container->setDefinition('test', $definition);
     $test = $container->get('test');
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:20,代碼來源:ContainerBuilderTest.php

示例6: merge

 /**
  * Merges a ContainerBuilder with the current ContainerBuilder configuration.
  *
  * Service definitions overrides the current defined ones.
  *
  * But for parameters, they are overridden by the current ones. It allows
  * the parameters passed to the container constructor to have precedence
  * over the loaded ones.
  *
  * $container = new ContainerBuilder(array('foo' => 'bar'));
  * $loader = new LoaderXXX($container);
  * $loader->load('resource_name');
  * $container->register('foo', new stdClass());
  *
  * In the above example, even if the loaded resource defines a foo
  * parameter, the value will still be 'bar' as defined in the ContainerBuilder
  * constructor.
  */
 public function merge(ContainerBuilder $container)
 {
     if (true === $this->isFrozen()) {
         throw new \LogicException('Cannot merge on a frozen container.');
     }
     $this->addDefinitions($container->getDefinitions());
     $this->addAliases($container->getAliases());
     $this->addInterfaceInjectors($container->getInterfaceInjectors());
     $this->parameterBag->add($container->getParameterBag()->all());
     foreach ($container->getResources() as $resource) {
         $this->addResource($resource);
     }
     foreach ($container->getExtensionConfigs() as $name => $configs) {
         if (isset($this->extensionConfigs[$name])) {
             $this->extensionConfigs[$name] = array_merge($this->extensionConfigs[$name], $configs);
         } else {
             $this->extensionConfigs[$name] = $configs;
         }
     }
 }
開發者ID:spf13,項目名稱:symfony,代碼行數:38,代碼來源:ContainerBuilder.php

示例7: testLoadInterfaceInjectors

 public function testLoadInterfaceInjectors()
 {
     $container = new ContainerBuilder();
     $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath . '/xml'));
     $loader->load('interfaces1.xml');
     $interfaces = $container->getInterfaceInjectors('FooClass');
     $this->assertEquals(1, count($interfaces), '->load() parses <interface> elements');
     $interface = $interfaces['FooClass'];
     $this->assertTrue($interface->hasMethodCall('setBar'), '->load() applies method calls correctly');
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:10,代碼來源:XmlFileLoaderTest.php


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