8000 [HttpKernel] Fix merging bindings for controllers' locators by nicolas-grekas · Pull Request #28052 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Fix merging bindings for controllers' locators #28052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[HttpKernel] Fix merging bindings for controllers' locators
  • Loading branch information
nicolas-grekas committed Jul 24, 2018
commit 94b620ebc2bfb8c0fc045dcf2e7f5fb4840384ba
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function process(ContainerBuilder $container)
while ($def instanceof ChildDefinition) {
$def = $container->findDefinition($def->getParent());
$class = $class ?: $def->getClass();
$bindings = $def->getBindings();
$bindings += $def->getBindings();
}
$class = $parameterBag->resolveValue($class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

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;
Expand Down Expand Up @@ -326,6 +327,29 @@ public function testDoNotBindScalarValueToControllerArgument()
$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
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
0