8000 bug #27415 Insert correct parameter_bag service in AbstractController… · symfony/symfony@ce616bf · GitHub
[go: up one dir, main page]

Skip to content

Commit ce616bf

Browse files
bug #27415 Insert correct parameter_bag service in AbstractController (curry684)
This PR was submitted for the master branch but it was squashed and merged into the 4.1 branch instead (closes #27415). Discussion ---------- Insert correct parameter_bag service in AbstractController Reverts this feature being broken in 3051289#diff-ef10778bc68793f8c8f4b71a7ba67790R86 - `getParameter` could never work now as it was querying the container itself instead of the parameter bag. | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | License | MIT Also see comments at #25439 (comment) Commits ------- 37270d7 Insert correct parameter_bag service in AbstractController
2 parents e0ec1f3 + 37270d7 commit ce616bf

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Controller/AbstractController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Container\ContainerInterface;
1515
use Doctrine\Common\Persistence\ManagerRegistry;
16+
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
1617
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
1718
use Symfony\Component\Form\FormFactoryInterface;
1819
use Symfony\Component\HttpFoundation\RequestStack;
@@ -84,7 +85,7 @@ public static function getSubscribedServices()
8485
'form.factory' => '?'.FormFactoryInterface::class,
8586
'security.token_storage' => '?'.TokenStorageInterface::class,
8687
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
87-
'parameter_bag' => '?'.ContainerInterface::class,
88+
'parameter_bag' => '?'.ContainerBagInterface::class,
8889
'message_bus' => '?'.MessageBusInterface::class,
8990
);
9091
}

src/Symfony/Bundle/FrameworkBundle/Tests/Controller/AbstractControllerTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,32 @@ protected function createController()
2424
return new TestAbstractController();
2525
}
2626

27+
/**
28+
* This test protects the default subscribed core services against accidental modification.
29+
*/
30+
public function testSubscribedServices()
31+
{
32+
$subscribed = AbstractController::getSubscribedServices();
33+
$expectedServices = array(
34+
'router' => '?Symfony\\Component\\Routing\\RouterInterface',
35+
'request_stack' => '?Symfony\\Component\\HttpFoundation\\RequestStack',
36+
'http_kernel' => '?Symfony\\Component\\HttpKernel\\HttpKernelInterface',
37+
'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface',
38+
'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface',
39+
'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface',
40+
'templating' => '?Symfony\\Component\\Templating\\EngineInterface',
41+
'twig' => '?Twig\\Environment',
42+
'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry',
43+
'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface',
44+
'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface',
45+
'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface',
46+
'security.token_storage' => '?Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface',
47+
'security.csrf.token_manager' => '?Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface',
48+
);
49+
50+
$this->assertEquals($expectedServices, $subscribed, 'Subscribed core services in AbstractController have changed');
51+
}
52+
2753
public function testGetParameter()
2854
{
2955
$container = new Container(new FrozenParameterBag(array('foo' => 'bar')));

0 commit comments

Comments
 (0)
0