From 2b07de5a850d956eb1ab6d9f828923f300d7b29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Thu, 13 Apr 2017 22:14:12 +0200 Subject: [PATCH] Remove usage of request service --- bundle/Controller/LegacySetupController.php | 2 +- mvc/Kernel/Loader.php | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bundle/Controller/LegacySetupController.php b/bundle/Controller/LegacySetupController.php index b9b4b73c..ed9803cc 100644 --- a/bundle/Controller/LegacySetupController.php +++ b/bundle/Controller/LegacySetupController.php @@ -87,7 +87,7 @@ public function init() $this->kernelFactory->setBuildEventsEnabled(false); /** @var $request \Symfony\Component\HttpFoundation\ParameterBag */ - $request = $this->container->get('request')->request; + $request = $this->container->get('request_stack')->getCurrentRequest()->request; // inject the extra ezpublish-community folders we want permissions checked for switch ($request->get('eZSetup_current_step')) { diff --git a/mvc/Kernel/Loader.php b/mvc/Kernel/Loader.php index 5848f9e9..d0842eef 100644 --- a/mvc/Kernel/Loader.php +++ b/mvc/Kernel/Loader.php @@ -21,6 +21,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\ParameterBag; +use Symfony\Component\HttpFoundation\RequestStack; /** * Legacy kernel loader. @@ -68,6 +69,11 @@ class Loader /** @var ezpKernelHandler */ private $restHandler; + /** + * @var \Symfony\Component\HttpFoundation\RequestStack + */ + private $requestStack; + public function __construct($legacyRootDir, $webrootDir, EventDispatcherInterface $eventDispatcher, URIHelper $uriHelper, LoggerInterface $logger = null) { $this->legacyRootDir = $legacyRootDir; @@ -77,6 +83,14 @@ public function __construct($legacyRootDir, $webrootDir, EventDispatcherInterfac $this->logger = $logger; } + /** + * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack + */ + public function setRequestStack(RequestStack $requestStack) + { + $this->requestStack = $requestStack; + } + /** * @param bool $enabled */ @@ -152,7 +166,7 @@ public function buildLegacyKernelHandlerWeb($webHandlerClass, array $defaultLega $legacyParameters = new ParameterBag($defaultLegacyOptions); $legacyParameters->set('service-container', $container); - $request = $container->get('request'); + $request = $this->requestStack->getCurrentRequest(); if ($that->getBuildEventsEnabled()) { // PRE_BUILD_LEGACY_KERNEL for non request related stuff @@ -277,7 +291,7 @@ public function buildLegacyKernelHandlerRest($mvcConfiguration) chdir($legacyRootDir); $legacyParameters = new ParameterBag(); - $request = $container->get('request'); + $request = $this->requestStack->getCurrentRequest(); if ($that->getBuildEventsEnabled()) { // PRE_BUILD_LEGACY_KERNEL for non request related stuff