[HttpKernel] Fix merging bindings for controllers' locators
This commit is contained in:
parent
d61bedabd5
commit
94b620ebc2
@ -60,7 +60,7 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
while ($def instanceof ChildDefinition) {
|
||||
$def = $container->findDefinition($def->getParent());
|
||||
$class = $class ?: $def->getClass();
|
||||
$bindings = $def->getBindings();
|
||||
$bindings += $def->getBindings();
|
||||
}
|
||||
$class = $parameterBag->resolveValue($class);
|
||||
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
@ -326,6 +327,29 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$this->assertEmpty($locator);
|
||||
}
|
||||
|
||||
public function testBindingsOnChildDefinitions()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$resolver = $container->register('argument_resolver.service')->addArgument(array());
|
||||
|
||||
$container->register('parent', ArgumentWithoutTypeController::class);
|
||||
|
||||
$container->setDefinition('child', (new ChildDefinition('parent'))
|
||||
->setBindings(array('$someArg' => new Reference('parent')))
|
||||
->addTag('controller.service_arguments')
|
||||
);
|
||||
|
||||
$pass = new RegisterControllerArgumentLocatorsPass();
|
||||
$pass->process($container);
|
||||
|
||||
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
|
||||
$this->assertInstanceOf(ServiceClosureArgument::class, $locator['child:fooAction']);
|
||||
|
||||
$locator = $container->getDefinition((string) $locator['child:fooAction']->getValues()[0])->getArgument(0);
|
||||
$this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']);
|
||||
$this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
class RegisterTestController
|
||||
|
@ -29,7 +29,7 @@
|
||||
"symfony/config": "~2.8|~3.0|~4.0",
|
||||
"symfony/console": "~2.8|~3.0|~4.0",
|
||||
"symfony/css-selector": "~2.8|~3.0|~4.0",
|
||||
"symfony/dependency-injection": "^3.4.5|^4.0.5",
|
||||
"symfony/dependency-injection": "^3.4.10|^4.0.10",
|
||||
"symfony/dom-crawler": "~2.8|~3.0|~4.0",
|
||||
"symfony/expression-language": "~2.8|~3.0|~4.0",
|
||||
"symfony/finder": "~2.8|~3.0|~4.0",
|
||||
@ -46,7 +46,7 @@
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<2.8",
|
||||
"symfony/dependency-injection": "<3.4.5|<4.0.5,>=4",
|
||||
"symfony/dependency-injection": "<3.4.10|<4.0.10,>=4",
|
||||
"symfony/var-dumper": "<3.3",
|
||||
"twig/twig": "<1.34|<2.4,>=2"
|
||||
},
|
||||
|
Reference in New Issue
Block a user