Skip to content

Commit 38d71d6

Browse files
smnandrenicolas-grekas
authored andcommitted
[HttpKernel] Ensure controllers are not lazy
Fix symfony#54542
1 parent 3faeb57 commit 38d71d6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public function process(ContainerBuilder $container)
7070
foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) {
7171
$def = $container->getDefinition($id);
7272
$def->setPublic(true);
73+
$def->setLazy(false);
7374
$class = $def->getClass();
7475
$autowire = $def->isAutowired();
7576
$bindings = $def->getBindings();

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Symfony\Component\DependencyInjection\TypedReference;
2626
use Symfony\Component\HttpFoundation\Response;
2727
use Symfony\Component\HttpKernel\DependencyInjection\RegisterControllerArgumentLocatorsPass;
28+
use Symfony\Component\HttpKernel\Tests\Fixtures\DataCollector\DummyController;
2829
use Symfony\Component\HttpKernel\Tests\Fixtures\Suit;
2930

3031
class RegisterControllerArgumentLocatorsPassTest extends TestCase
@@ -285,6 +286,21 @@ public function testControllersAreMadePublic()
285286
$this->assertTrue($container->getDefinition('foo')->isPublic());
286287
}
287288

289+
public function testControllersAreMadeNonLazy()
290+
{
291+
$container = new ContainerBuilder();
292+
$container->register('argument_resolver.service')->addArgument([]);
293+
294+
$container->register('foo', DummyController::class)
295+
->addTag('controller.service_arguments')
296+
->setLazy(true);
297+
298+
$pass = new RegisterControllerArgumentLocatorsPass();
299+
$pass->process($container);
300+
301+
$this->assertFalse($container->getDefinition('foo')->isLazy());
302+
}
303+
288304
/**
289305
* @dataProvider provideBindings
290306
*/

0 commit comments

Comments
 (0)