Merge branch '2.6' into 2.7
* 2.6: [DependencyInjection] fixed service resolution for factories [acl][command][SecurityBundle] Fixed user input option mode to be an Array Conflicts: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
This commit is contained in:
commit
a003380c39
@ -78,7 +78,7 @@ To set permissions at the class scope, use the <info>--class-scope</info> option
|
||||
EOF
|
||||
)
|
||||
->addArgument('arguments', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'A list of permissions and object identities (class name and ID separated by a column)')
|
||||
->addOption('user', null, InputOption::VALUE_REQUIRED, 'A list of security identities')
|
||||
->addOption('user', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A list of security identities')
|
||||
->addOption('role', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'A list of roles')
|
||||
->addOption('class-scope', null, InputOption::VALUE_NONE, 'Use class-scope entries')
|
||||
;
|
||||
|
@ -37,6 +37,9 @@ class ResolveParameterPlaceHoldersPass implements CompilerPassInterface
|
||||
$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()));
|
||||
}
|
||||
|
||||
$calls = array();
|
||||
foreach ($definition->getMethodCalls() as $name => $arguments) {
|
||||
|
@ -1338,7 +1338,9 @@ EOF;
|
||||
if (null !== $value->getFactoryClass(false)) {
|
||||
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass(false)), $value->getFactoryMethod(false), count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
|
||||
} elseif (null !== $value->getFactoryService(false)) {
|
||||
return sprintf("%s->%s(%s)", $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
|
||||
$service = $this->dumpValue($definition->getFactoryService(false));
|
||||
|
||||
return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
|
||||
} else {
|
||||
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
|
||||
}
|
||||
|
@ -333,6 +333,42 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($builder->get('baz')->called, '->createService() uses another service as factory');
|
||||
}
|
||||
|
||||
public function testLegacyCreateServiceFactory()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('bar', 'Bar\FooClass');
|
||||
$builder
|
||||
->register('foo1', 'Bar\FooClass')
|
||||
->setFactoryClass('%foo_class%')
|
||||
->setFactoryMethod('getInstance')
|
||||
->addArgument(array('foo' => '%value%', '%value%' => 'foo', new Reference('bar')))
|
||||
;
|
||||
$builder->setParameter('value', 'bar');
|
||||
$builder->setParameter('foo_class', 'Bar\FooClass');
|
||||
$this->assertTrue($builder->get('foo1')->called, '->createService() calls the factory method to create the service instance');
|
||||
$this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', $builder->get('bar')), $builder->get('foo1')->arguments, '->createService() passes the arguments to the factory method');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
|
||||
*/
|
||||
public function testLegacyCreateServiceFactoryService()
|
||||
{
|
||||
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
|
||||
|
||||
$builder = new ContainerBuilder();
|
||||
$builder->register('foo_service', 'Bar\FooClass');
|
||||
$builder
|
||||
->register('foo', 'Bar\FooClass')
|
||||
->setFactoryService('%foo_service%')
|
||||
->setFactoryMethod('getInstance')
|
||||
;
|
||||
$builder->setParameter('foo_service', 'foo_service');
|
||||
$this->assertTrue($builder->get('foo')->called, '->createService() calls the factory method to create the service instance');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Symfony\Component\DependencyInjection\ContainerBuilder::createService
|
||||
*/
|
||||
|
Reference in New Issue
Block a user