Skip to content

Commit

Permalink
TASK: Use server request globals when active request handler doesn't …
Browse files Browse the repository at this point in the history
…exist

Addresses #234
  • Loading branch information
Janett Salzmann committed Mar 28, 2024
1 parent 59f548e commit b031c37
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Classes/Service/UsageDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Neos\Flow\Core\Bootstrap;
use Neos\Flow\Exception as FlowException;
use Neos\Flow\Http\Exception as HttpException;
use Neos\Flow\Http\HttpRequestHandlerInterface;
use Neos\Flow\I18n\Translator;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\Exception\MissingActionNameException;
Expand Down Expand Up @@ -333,7 +334,14 @@ protected function usageIsAccessible(string $workspaceName): bool
*/
protected function buildNodeUri(?Site $site, NodeInterface $node): string
{
$serverRequest = $this->bootstrap->getActiveRequestHandler()->getHttpRequest();
$requestHandler = $this->bootstrap->getActiveRequestHandler();

if ($requestHandler instanceof HttpRequestHandlerInterface) {
$serverRequest = $requestHandler->getHttpRequest();
} else {
$serverRequest = ServerRequest::fromGlobals();
}

$domain = $site ? $site->getPrimaryDomain() : null;

// Build the URI with the correct scheme and hostname for the node in the given site
Expand Down

0 comments on commit b031c37

Please sign in to comment.