Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 66d2268

Browse filesBrowse files
committed
[HttpKernel] add test for using Target with controller args
1 parent aa51dc7 commit 66d2268
Copy full SHA for 66d2268

File tree

Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public function process(ContainerBuilder $container)
175175
$args[$p->name] = new Reference($erroredId, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE);
176176
} else {
177177
$target = ltrim($target, '\\');
178-
$args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, $p->name) : new Reference($target, $invalidBehavior);
178+
$args[$p->name] = $type ? new TypedReference($target, $type, $invalidBehavior, Target::parseName($p)) : new Reference($target, $invalidBehavior);
179179
}
180180
}
181181
// register the maps as a per-method service-locators

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ public function testBindWithTarget()
422422
$container = new ContainerBuilder();
423423
$resolver = $container->register('argument_resolver.service')->addArgument([]);
424424

425+
$container->register(ControllerDummy::class, 'bar');
426+
$container->register(ControllerDummy::class.' $imageStorage', 'baz');
427+
425428
$container->register('foo', WithTarget::class)
426429
->setBindings(['string $someApiKey' => new Reference('the_api_key')])
427430
->addTag('controller.service_arguments');
@@ -431,7 +434,11 @@ public function testBindWithTarget()
431434
$locator = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
432435
$locator = $container->getDefinition((string) $locator['foo::fooAction']->getValues()[0]);
433436

434-
$expected = ['apiKey' => new ServiceClosureArgument(new Reference('the_api_key'))];
437+
$expected = [
438+
'apiKey' => new ServiceClosureArgument(new Reference('the_api_key')),
439+
'service1' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE, 'imageStorage')),
440+
'service2' => new ServiceClosureArgument(new TypedReference(ControllerDummy::class, ControllerDummy::class, ContainerInterface::RUNTIME_EXCEPTION_ON_INVALID_REFERENCE, 'service2')),
441+
];
435442
$this->assertEquals($expected, $locator->getArgument(0));
436443
}
437444
}
@@ -507,7 +514,10 @@ class WithTarget
507514
{
508515
public function fooAction(
509516
#[Target('some.api.key')]
510-
string $apiKey
517+
string $apiKey,
518+
#[Target('image.storage')]
519+
ControllerDummy $service1,
520+
ControllerDummy $service2
511521
) {
512522
}
513523
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.