本文整理汇总了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));
}
}
示例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);
}
}
}
}
示例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);
}
}
}
}
示例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');
}
示例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');
}
示例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;
}
}
}
示例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');
}