8000 bug #28052 [HttpKernel] Fix merging bindings for controllers' locator… · symfony/symfony@1b9baa4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1b9baa4

Browse files
bug #28052 [HttpKernel] Fix merging bindings for controllers' locators (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [HttpKernel] Fix merging bindings for controllers' locators | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28041 | License | MIT | Doc PR | - Commits ------- 94b620e [HttpKernel] Fix merging bindings for controllers' locators
2 parents 0ff03c9 + 94b620e commit 1b9baa4

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(ContainerBuilder $container)
6060
while ($def instanceof ChildDefinition) {
6161
$def = $container->findDefinition($def->getParent());
6262
$class = $class ?: $def->getClass();
63-
$bindings = $def->getBindings();
63+
$bindings += $def->getBindings();
6464
}
6565
$class = $parameterBag->resolveValue($class);
6666

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
16+
use Symfony\Component\DependencyInjection\ChildDefinition;
1617
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1718
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
1819
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -326,6 +327,29 @@ public function testDoNotBindScalarValueToControllerArgument()
326327
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
327328
$this->assertEmpty($locator);
328329
}
330+
331+
public function testBindingsOnChildDefinitions()
332+
{
333+
$container = new ContainerBuilder();
334+
$resolver = $container->register('argument_resolver.service')->addArgument(array());
335+
336+
$container->register('parent', ArgumentWithoutTypeController::class);
337+
338+
$container->setDefinition('child', (new ChildDefinition('parent'))
339+
->setBindings(array('$someArg' => new Reference('parent')))
340+
->addTag('controller.service_arguments')
341+
);
342+
343+
$pass = new RegisterControllerArgumentLocatorsPass();
344+
$pass->process($container);
345+
346+
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
347+
$this->assertInstanceOf(ServiceClosureArgument::class, $locator['child:fooAction']);
348+
349+
$locator = $container->getDefinition((string) $locator['child:fooAction']->getValues()[0])->getArgument(0);
350+
$this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']);
351+
$this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]);
352+
}
329353
}
330354

331355
class RegisterTestController

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/config": "~2.8|~3.0|~4.0",
3030
"symfony/console": "~2.8|~3.0|~4.0",
3131
"symfony/css-selector": "~2.8|~3.0|~4.0",
32-
"symfony/dependency-injection": "^3.4.5|^4.0.5",
32+
"symfony/dependency-injection": "^3.4.10|^4.0.10",
3333
"symfony/dom-crawler": "~2.8|~3.0|~4.0",
3434
"symfony/expression-language": "~2.8|~3.0|~4.0",
3535
"symfony/finder": "~2.8|~3.0|~4.0",
@@ -46,7 +46,7 @@
4646
},
4747
"conflict": {
4848
"symfony/config": "<2.8",
49-
"symfony/dependency-injection": "<3.4.5|<4.0.5,>=4",
49+
"symfony/dependency-injection": "<3.4.10|<4.0.10,>=4",
5050
"symfony/var-dumper": "<3.3",
5151
"twig/twig": "<1.34|<2.4,>=2"
5252
},

0 commit comments

Comments
 (0)
0