当前位置: 首页>>代码示例>>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;未经允许,请勿转载。