Skip to content

Commit

Permalink
Merge pull request #40 from neos/bugfix/psr-7-compatibility
Browse files Browse the repository at this point in the history
BUGFIX: Compatibility with PSR-7 changes in Flow
  • Loading branch information
Sebobo authored Sep 6, 2019
2 parents e61d665 + b52193e commit 1a22e57
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions Classes/Service/NodeRedirectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
use Neos\ContentRepository\Domain\Service\ContentDimensionCombinator;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Request;
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
use Neos\Flow\Mvc\Routing\RouterCachingService;
Expand Down Expand Up @@ -80,6 +81,12 @@ class NodeRedirectService
*/
protected $logger;

/**
* @var Bootstrap
* @Flow\Inject
*/
protected $bootstrap;

/**
* @Flow\InjectConfiguration(path="statusCode", package="Neos.RedirectHandler")
* @var array
Expand Down Expand Up @@ -475,8 +482,16 @@ protected function getUriBuilder(): UriBuilder
return $this->uriBuilder;
}

$httpRequest = Request::createFromEnvironment();
$actionRequest = new ActionRequest($httpRequest);
/** @var HttpRequestHandlerInterface $requestHandler */
$requestHandler = $this->bootstrap->getActiveRequestHandler();
if (method_exists(ActionRequest::class, 'fromHttpRequest')) {
// From Flow 6+ we have to use a static method to create an ActionRequest. Earlier versions use the constructor.
$actionRequest = ActionRequest::fromHttpRequest($requestHandler->getHttpRequest());
} else {
// This can be cleaned up when this package in a future release only support Flow 6+.
$actionRequest = new ActionRequest($requestHandler->getHttpRequest());
}

$this->uriBuilder = new UriBuilder();
$this->uriBuilder
->setRequest($actionRequest);
Expand Down

0 comments on commit 1a22e57

Please sign in to comment.