Skip to content

Commit

Permalink
Merge pull request #3703 from mhsdesign/task/avoidHeavilyUseOfControl…
Browse files Browse the repository at this point in the history
…lerContext

TASK: Avoid heavily use of controller context and make `Neos.Ui.NodeInfo` internal
  • Loading branch information
mhsdesign authored Feb 14, 2024
2 parents 13dccc9 + ce7cd45 commit 0d87792
Show file tree
Hide file tree
Showing 14 changed files with 87 additions and 139 deletions.
6 changes: 3 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ public function indexAction(string $node = null)
),
'frontendConfiguration' =>
$this->frontendConfigurationProvider->getFrontendConfiguration(
controllerContext: $this->controllerContext,
actionRequest: $this->request,
),
'nodeTypes' =>
$this->nodeTypeGroupsAndRolesProvider->getNodeTypes(),
'menu' =>
$this->menuProvider->getMenu(
controllerContext: $this->controllerContext,
actionRequest: $this->request,
),
'initialState' =>
$this->initialStateProvider->getInitialState(
controllerContext: $this->controllerContext,
actionRequest: $this->request,
contentRepositoryId: $siteDetectionResult->contentRepositoryId,
documentNode: $node,
site: $siteNode,
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,15 +590,15 @@ public function flowQueryAction(array $chain): string
$nodeInfoHelper = new NodeInfoHelper();
$type = $finisher['type'] ?? null;
$result = match ($type) {
'get' => $nodeInfoHelper->renderNodes(array_filter($flowQuery->get()), $this->getControllerContext()),
'get' => $nodeInfoHelper->renderNodes(array_filter($flowQuery->get()), $this->request),
'getForTree' => $nodeInfoHelper->renderNodes(
array_filter($flowQuery->get()),
$this->getControllerContext(),
$this->request,
true
),
'getForTreeWithParents' => $nodeInfoHelper->renderNodesWithParents(
array_filter($flowQuery->get()),
$this->getControllerContext()
$this->request
),
default => []
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Neos\Neos\Ui\Domain\InitialData;

use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\ActionRequest;

/**
* Reads and preprocesses the `Neos.Neos.Ui.frontendConfiguration` settings
Expand All @@ -27,6 +27,6 @@ interface FrontendConfigurationProviderInterface
{
/** @return array<mixed> */
public function getFrontendConfiguration(
ControllerContext $controllerContext
ActionRequest $actionRequest
): array;
}
4 changes: 2 additions & 2 deletions Classes/Domain/InitialData/InitialStateProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use Neos\ContentRepository\Core\Factory\ContentRepositoryId;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Domain\Model\User;

/**
Expand All @@ -29,7 +29,7 @@ interface InitialStateProviderInterface
{
/** @return array<mixed> */
public function getInitialState(
ControllerContext $controllerContext,
ActionRequest $actionRequest,
ContentRepositoryId $contentRepositoryId,
?Node $documentNode,
?Node $site,
Expand Down
4 changes: 2 additions & 2 deletions Classes/Domain/InitialData/MenuProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Neos\Neos\Ui\Domain\InitialData;

use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Flow\Mvc\ActionRequest;

/**
* Retrieves all data needed to render the main burger menu located in the
Expand All @@ -27,5 +27,5 @@ interface MenuProviderInterface
/**
* @return array<int,array{label:string,icon:string,uri:string,target:string,children:array<int,array{icon:string,label:string,uri:string,position?:string,isActive:bool,target:string,skipI18n:bool}>}>
*/
public function getMenu(ControllerContext $controllerContext): array;
public function getMenu(ActionRequest $actionRequest): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function serializePayload(ControllerContext $controllerContext): array

if ($documentNode) {
return [
'uri' => $nodeInfoHelper->previewUri($documentNode, $controllerContext)
'uri' => $nodeInfoHelper->previewUri($documentNode, $controllerContext->getRequest())
];
}

Expand Down
9 changes: 5 additions & 4 deletions Classes/Domain/Model/Feedback/Operations/UpdateNodeInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
Expand Down Expand Up @@ -106,7 +107,7 @@ public function serializePayload(ControllerContext $controllerContext): array
{
return $this->node
? [
'byContextPath' => $this->serializeNodeRecursively($this->node, $controllerContext)
'byContextPath' => $this->serializeNodeRecursively($this->node, $controllerContext->getRequest())
]
: [];
}
Expand All @@ -116,7 +117,7 @@ public function serializePayload(ControllerContext $controllerContext): array
*
* @return array<string,?array<string,mixed>>
*/
private function serializeNodeRecursively(Node $node, ControllerContext $controllerContext): array
private function serializeNodeRecursively(Node $node, ActionRequest $actionRequest): array
{
$contentRepository = $this->contentRepositoryRegistry->get($node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
Expand All @@ -125,14 +126,14 @@ private function serializeNodeRecursively(Node $node, ControllerContext $control
$nodeAddressFactory->createFromNode($node)->serializeForUri()
=> $this->nodeInfoHelper->renderNodeWithPropertiesAndChildrenInformation(
$node,
$controllerContext
$actionRequest
)
];

if ($this->isRecursive === true) {
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($node);
foreach ($subgraph->findChildNodes($node->nodeAggregateId, FindChildNodesFilter::create()) as $childNode) {
$result = array_merge($result, $this->serializeNodeRecursively($childNode, $controllerContext));
$result = array_merge($result, $this->serializeNodeRecursively($childNode, $actionRequest));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function serializePayload(ControllerContext $controllerContext): array
$nodeInfoHelper = new NodeInfoHelper();
$contentRepository = $this->contentRepositoryRegistry->get($this->node->subgraphIdentity->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$newPreviewUrl = $nodeInfoHelper->createRedirectToNode($this->node, $controllerContext);
$newPreviewUrl = $nodeInfoHelper->createRedirectToNode($this->node, $controllerContext->getRequest());
$contextPath = $nodeAddressFactory->createFromNode($this->node)->serializeForUri();
}
return [
Expand Down
Loading

0 comments on commit 0d87792

Please sign in to comment.