Skip to content

Commit

Permalink
Remove usage of request service
Browse files Browse the repository at this point in the history
  • Loading branch information
emodric committed Apr 13, 2017
1 parent c5ce7ad commit 583c928
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bundle/Controller/LegacySetupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
1 change: 1 addition & 0 deletions bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ services:
- "@?logger"
calls:
- [setContainer, ["@service_container"]]
- [setRequestStack, ["@request_stack"]]

ezpublish_legacy.rest.kernel_handler:
class: "%ezpublish_legacy.kernel_handler.rest.class%"
Expand Down
18 changes: 16 additions & 2 deletions mvc/Kernel/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 583c928

Please sign in to comment.