Permalink
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
  • Loading branch information...
nicolas-grekas committed May 30, 2018
2 parents e0ec1f3 + 37270d7 commit ce616bf5790df9803dfba1ac7c60fea7fb2e3da1
@@ -13,6 +13,7 @@
use Psr\Container\ContainerInterface;
use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -84,7 +85,7 @@ public static function getSubscribedServices()
'form.factory' => '?'.FormFactoryInterface::class,
'security.token_storage' => '?'.TokenStorageInterface::class,
'security.csrf.token_manager' => '?'.CsrfTokenManagerInterface::class,
'parameter_bag' => '?'.ContainerInterface::class,
'parameter_bag' => '?'.ContainerBagInterface::class,
'message_bus' => '?'.MessageBusInterface::class,
);
}
@@ -24,6 +24,32 @@ protected function createController()
return new TestAbstractController();
}
/**
* This test protects the default subscribed core services against accidental modification.
*/
public function testSubscribedServices()
{
$subscribed = AbstractController::getSubscribedServices();
$expectedServices = array(
'router' => '?Symfony\\Component\\Routing\\RouterInterface',
'request_stack' => '?Symfony\\Component\\HttpFoundation\\RequestStack',
'http_kernel' => '?Symfony\\Component\\HttpKernel\\HttpKernelInterface',
'serializer' => '?Symfony\\Component\\Serializer\\SerializerInterface',
'session' => '?Symfony\\Component\\HttpFoundation\\Session\\SessionInterface',
'security.authorization_checker' => '?Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface',
'templating' => '?Symfony\\Component\\Templating\\EngineInterface',
'twig' => '?Twig\\Environment',
'doctrine' => '?Doctrine\\Common\\Persistence\\ManagerRegistry',
'form.factory' => '?Symfony\\Component\\Form\\FormFactoryInterface',
'parameter_bag' => '?Symfony\\Component\\DependencyInjection\\ParameterBag\\ContainerBagInterface',
'message_bus' => '?Symfony\\Component\\Messenger\\MessageBusInterface',
'security.token_storage' => '?Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface',
'security.csrf.token_manager' => '?Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface',
);
$this->assertEquals($expectedServices, $subscribed, 'Subscribed core services in AbstractController have changed');
}
public function testGetParameter()
{
$container = new Container(new FrozenParameterBag(array('foo' => 'bar')));

0 comments on commit ce616bf

Please sign in to comment.