Skip to content

Commit

Permalink
TASK: Pass ActionRequest instead of destructuring HttpRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jun 5, 2024
1 parent 95f1c5e commit b08d248
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Controller/Frontend/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ protected function handleShortcutNode(NodeAddress $nodeAddress): void
return;
}
try {
$resolvedUri = $this->nodeUriBuilderFactory->forRequest($this->request->getHttpRequest())
$resolvedUri = $this->nodeUriBuilderFactory->forActionRequest($this->request)
->uriFor($nodeAddress);
} catch (NoMatchingRouteException $e) {
throw new NodeNotFoundException(sprintf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public function rebaseAndRedirectAction(Node $targetNode, Workspace $targetWorks
}

$this->redirectToUri(
$this->nodeUriBuilderFactory->forRequest($this->request->getHttpRequest())
$this->nodeUriBuilderFactory->forActionRequest($this->request)
->uriFor($targetNodeAddressInPersonalWorkspace)
);
}
Expand Down
4 changes: 2 additions & 2 deletions Neos.Neos/Classes/FrontendRouting/NodeUri/NodeUriBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/**
* Neos abstraction to simplify node uri building.
*
* Builds URIs to nodes, taking workspace (live / shared / user) into account.
* Builds URIs to nodes, taking workspace (live / shared / user) into account.
* Can also be used in order to render "preview" URLs to nodes, that are not
* in the live workspace (in the Neos Backend and shared workspaces)
*
Expand Down Expand Up @@ -78,7 +78,7 @@ public function __construct(
* Cross-linking nodes
* -------------------
*
* Cross linking to a node happens when the side determined based on the current
* Cross linking to a node happens when the site determined based on the current
* route parameters (through the host and sites domain) does not belong to the linked node.
* In this case the domain from the node's site might be used to build a host absolute uri {@see CrossSiteLinkerInterface}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Http\Helper\RequestInformationHelper;
use Neos\Flow\Http\ServerRequestAttributes;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Routing\Dto\RouteParameters;
use Neos\Flow\Mvc\Routing\RouterInterface;
use Psr\Http\Message\ServerRequestInterface;

/**
* @api
*/
#[Flow\Scope('singleton')]
final class NodeUriBuilderFactory
{
Expand All @@ -25,11 +28,10 @@ final class NodeUriBuilderFactory
#[Flow\Inject]
protected RouterInterface $router;

/**
* @api
*/
public function forRequest(ServerRequestInterface $request): NodeUriBuilder
public function forActionRequest(ActionRequest $actionRequest): NodeUriBuilder
{
$request = $actionRequest->getHttpRequest();

$baseUri = $this->configuredBaseUri !== null
? new Uri($this->configuredBaseUri)
: RequestInformationHelper::generateBaseUri($request);
Expand Down
9 changes: 4 additions & 5 deletions Neos.Neos/Classes/Fusion/ConvertUrisImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,12 @@ public function evaluate()
);
$possibleRequest = $this->runtime->fusionGlobals->get('request');
if ($possibleRequest instanceof ActionRequest) {
$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest($possibleRequest->getHttpRequest());
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($possibleRequest);
} else {
// unfortunately, the uri-builder always needs a request at hand and cannot build uris without
// even, if the default param merging would not be required
// unfortunately, the uri-builder always needs a request at hand and cannot build uris without it
// this will improve with a reformed uri building:
// https://github.com/neos/flow-development-collection/pull/2744
$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest(ServerRequest::fromGlobals());
// https://github.com/neos/flow-development-collection/issues/3354
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest(ActionRequest::fromHttpRequest(ServerRequest::fromGlobals()));
}
try {
$resolvedUri = (string)$nodeUriBuilder->uriFor($nodeAddress, $options);
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/Fusion/Helper/LinkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function resolveNodeUri(
return null;
}

$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest($controllerContext->getRequest()->getHttpRequest());
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($controllerContext->getRequest());

try {
$targetUri = $nodeUriBuilder->uriFor(NodeAddress::fromNode($targetNode));
Expand Down
9 changes: 4 additions & 5 deletions Neos.Neos/Classes/Fusion/NodeUriImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ public function evaluate()

$possibleRequest = $this->runtime->fusionGlobals->get('request');
if ($possibleRequest instanceof ActionRequest) {
$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest($possibleRequest->getHttpRequest());
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($possibleRequest);
} else {
// unfortunately, the uri-builder always needs a request at hand and cannot build uris without
// even, if the default param merging would not be required
// unfortunately, the uri-builder always needs a request at hand and cannot build uris without it
// this will improve with a reformed uri building:
// https://github.com/neos/flow-development-collection/pull/2744
$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest(ServerRequest::fromGlobals());
// https://github.com/neos/flow-development-collection/issues/3354
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest(ActionRequest::fromHttpRequest(ServerRequest::fromGlobals()));
}

$options = Options::create(forceAbsolute: $this->isAbsolute());
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function render(): string
}
}

$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest($this->controllerContext->getRequest()->getHttpRequest());
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($this->controllerContext->getRequest());

$options = Options::create(forceAbsolute: $this->arguments['absolute']);
if ($format = $this->arguments['format']) {
Expand Down
2 changes: 1 addition & 1 deletion Neos.Neos/Classes/ViewHelpers/Uri/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function render(): string
), 1601372376);
}

$nodeUriBuilder = $this->nodeUriBuilderFactory->forRequest($this->controllerContext->getRequest()->getHttpRequest());
$nodeUriBuilder = $this->nodeUriBuilderFactory->forActionRequest($this->controllerContext->getRequest());

$options = Options::create(forceAbsolute: $this->arguments['absolute']);
if ($format = $this->arguments['format']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private function resolveUrl(string $nodeAggregateId, string $contentStreamId, st
$httpRequest = $this->addRoutingParameters($httpRequest);

return $this->getObject(NodeUriBuilderFactory::class)
->forRequest($httpRequest)
->forActionRequest(\Neos\Flow\Mvc\ActionRequest::fromHttpRequest($httpRequest))
->uriFor($nodeAddress);
}

Expand Down

0 comments on commit b08d248

Please sign in to comment.