Skip to content

Commit

Permalink
TASK: Remove usages to NodeAddressFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Oct 9, 2024
1 parent a42556f commit 13520de
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 90 deletions.
2 changes: 0 additions & 2 deletions Classes/Application/ReloadNodes/NodeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand Down
6 changes: 2 additions & 4 deletions Classes/Application/ReloadNodes/ReloadNodesQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;

/**
Expand Down Expand Up @@ -148,10 +148,8 @@ public function handle(ReloadNodesQuery $query, ActionRequest $actionRequest): R
- but the logic above mirrors the old behavior better.
https://github.com/neos/neos-ui/issues/3517#issuecomment-2070274053 */

$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return new ReloadNodesQueryResult(
documentId: $nodeAddressFactory->createFromNode($documentNode),
documentId: NodeAddress::fromNode($documentNode),
nodes: $nodeMapBuilder->build()
);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/Application/ReloadNodes/ReloadNodesQueryResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

namespace Neos\Neos\Ui\Application\ReloadNodes;

use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddress;

/**
* The application layer level query result containing all nodes the UI needs
Expand All @@ -38,7 +38,7 @@ public function __construct(
public function jsonSerialize(): array
{
return [
'documentId' => $this->documentId->serializeForUri(),
'documentId' => $this->documentId->toJson(),
'nodes' => $this->nodes
];
}
Expand Down
29 changes: 13 additions & 16 deletions Classes/ContentRepository/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\WorkspacePublishingService;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\PendingChangesProjection\Change;
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;

Expand Down Expand Up @@ -57,26 +56,26 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
$unpublishedNodes = [];
foreach ($pendingChanges as $change) {
if ($change->removalAttachmentPoint) {
$nodeAddress = new NodeAddress(
$change->contentStreamId,
$nodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->nodeAggregateId,
$workspaceName
$change->nodeAggregateId
);

/**
* See {@see Remove::apply} -> Removal Attachment Point == closest document node.
*/
$documentNodeAddress = new NodeAddress(
$change->contentStreamId,
$documentNodeAddress = NodeAddress::create(
$contentRepositoryId,
$workspaceName,
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
$change->removalAttachmentPoint,
$workspaceName
$change->removalAttachmentPoint
);

$unpublishedNodes[] = [
'contextPath' => $nodeAddress->serializeForUri(),
'documentContextPath' => $documentNodeAddress->serializeForUri(),
'contextPath' => $nodeAddress->toJson(),
'documentContextPath' => $documentNodeAddress->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
} else {
Expand All @@ -89,11 +88,9 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
if ($node instanceof Node) {
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
if ($documentNode instanceof Node) {
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$unpublishedNodes[] = [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'documentContextPath' => $nodeAddressFactory->createFromNode($documentNode)
->serializeForUri(),
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
'typeOfChange' => $this->getTypeOfChange($change)
];
}
Expand Down
5 changes: 2 additions & 3 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Neos\Neos\Domain\Repository\SiteRepository;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Domain\Service\WorkspaceService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
use Neos\Neos\Service\UserService;
Expand Down Expand Up @@ -136,7 +135,7 @@ public function indexAction(string $node = null)
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);

$nodeAddress = $node !== null ? NodeAddressFactory::create($contentRepository)->createFromUriString($node) : null;
$nodeAddress = $node !== null ? NodeAddress::fromJsonString($node) : null;
$user = $this->userService->getBackendUser();

if ($user === null) {
Expand Down Expand Up @@ -180,7 +179,7 @@ public function indexAction(string $node = null)
if (!$nodeAddress) {
$node = $siteNode;
} else {
$node = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
$node = $subgraph->findNodeById($nodeAddress->aggregateId);
}

$this->view->setOption('title', 'Neos CMS');
Expand Down
5 changes: 2 additions & 3 deletions Classes/Domain/Model/Changes/AbstractStructuralChange.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateClassification;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\ContentRepository\Service\NeosUiNodeService;
use Neos\Neos\Ui\Domain\Model\AbstractChange;
use Neos\Neos\Ui\Domain\Model\Feedback\Operations\ReloadDocument;
Expand Down Expand Up @@ -147,14 +147,13 @@ protected function finish(Node $node)
// 1) the parent of our new (or copied or moved) node is a ContentCollection;
// so we can directly update an element of this content collection

$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
if ($parentNode && $this->getNodeType($parentNode)?->isOfType('Neos.Neos:ContentCollection') &&
// 2) the parent DOM address (i.e. the closest RENDERED node in DOM is actually the ContentCollection;
// and no other node in between
$this->getParentDomAddress() &&
$this->getParentDomAddress()->getFusionPath() &&
$this->getParentDomAddress()->getContextPath() ===
NodeAddressFactory::create($contentRepository)->createFromNode($parentNode)->serializeForUri()
NodeAddress::fromNode($parentNode)->toJson()
) {
$renderContentOutOfBand = new RenderContentOutOfBand();
$renderContentOutOfBand->setNode($node);
Expand Down
8 changes: 4 additions & 4 deletions Classes/Domain/Model/Feedback/Operations/NodeCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* source code.
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
Expand Down Expand Up @@ -91,9 +91,9 @@ public function serializePayload(ControllerContext $controllerContext)
$node = $this->getNode();
$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
$nodeType = $contentRepository->getNodeTypeManager()->getNodeType($node->nodeTypeName);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return [
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'contextPath' => NodeAddress::fromNode($node)->toJson(),
'identifier' => $node->aggregateId->value,
'isDocument' => $nodeType?->isOfType(NodeTypeNameFactory::NAME_DOCUMENT)
];
Expand Down
4 changes: 1 addition & 3 deletions Classes/Domain/Model/Feedback/Operations/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
use Neos\Neos\FrontendRouting\Options;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
Expand Down Expand Up @@ -114,11 +113,10 @@ public function serializePayload(ControllerContext $controllerContext): array
);

$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

return [
'redirectUri' => (string)$redirectUri,
'redirectContextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
'redirectContextPath' => NodeAddress::fromNode($node)->toJson(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
* source code.
*/

use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Fusion\Core\Cache\ContentCache;
use Neos\Fusion\Exception as FusionException;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\Fusion\Helper\CachingHelper;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
Expand Down Expand Up @@ -110,10 +110,8 @@ public function isSimilarTo(FeedbackInterface $feedback): bool
public function serializePayload(ControllerContext $controllerContext): array
{
if (!is_null($this->nodeDomAddress)) {
$contentRepository = $this->contentRepositoryRegistry->get($this->node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
return [
'contextPath' => $nodeAddressFactory->createFromNode($this->node)->serializeForUri(),
'contextPath' => NodeAddress::fromNode($this->node)->toJson(),
'nodeDomAddress' => $this->nodeDomAddress,
'renderedContent' => $this->renderContent($controllerContext)
];
Expand Down
18 changes: 7 additions & 11 deletions Classes/Domain/Model/Feedback/Operations/RemoveNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
* source code.
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\FrontendRouting\NodeAddress;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;

Expand Down Expand Up @@ -54,11 +53,8 @@ public function __construct(Node $node, Node $parentNode)

protected function initializeObject(): void
{
$contentRepository = $this->contentRepositoryRegistry->get($this->node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$this->nodeAddress = $nodeAddressFactory->createFromNode($this->node);
$this->parentNodeAddress = $nodeAddressFactory->createFromNode($this->parentNode);
$this->nodeAddress = NodeAddress::fromNode($this->node);
$this->parentNodeAddress = NodeAddress::fromNode($this->parentNode);
}

public function getNode(): Node
Expand Down Expand Up @@ -110,8 +106,8 @@ public function isSimilarTo(FeedbackInterface $feedback)
public function serializePayload(ControllerContext $controllerContext)
{
return [
'contextPath' => $this->nodeAddress->serializeForUri(),
'parentContextPath' => $this->parentNodeAddress->serializeForUri()
'contextPath' => $this->nodeAddress->toJson(),
'parentContextPath' => $this->parentNodeAddress->toJson()
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
namespace Neos\Neos\Ui\Domain\Model\Feedback\Operations;

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Fusion\Core\Cache\ContentCache;
use Neos\Fusion\Exception as FusionException;
use Neos\Neos\Domain\Service\RenderingModeService;
use Neos\Neos\Fusion\Helper\CachingHelper;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
Expand Down Expand Up @@ -156,10 +156,8 @@ public function isSimilarTo(FeedbackInterface $feedback): bool
public function serializePayload(ControllerContext $controllerContext): array
{
if (!is_null($this->node)) {
$contentRepository = $this->contentRepositoryRegistry->get($this->node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
return [
'contextPath' => $nodeAddressFactory->createFromNode($this->node)->serializeForUri(),
'contextPath' => NodeAddress::fromNode($this->node)->toJson(),
'parentDomAddress' => $this->getParentDomAddress(),
'siblingDomAddress' => $this->getSiblingDomAddress(),
'mode' => $this->getMode(),
Expand Down
7 changes: 3 additions & 4 deletions Classes/Domain/Model/Feedback/Operations/UpdateNodeInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@

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\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\ActionRequest;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
Expand Down Expand Up @@ -115,10 +115,9 @@ public function serializePayload(ControllerContext $controllerContext): array
private function serializeNodeRecursively(Node $node, ActionRequest $actionRequest): array
{
$contentRepository = $this->contentRepositoryRegistry->get($node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);

$result = [
$nodeAddressFactory->createFromNode($node)->serializeForUri()
NodeAddress::fromNode($node)->toJson()
=> $this->nodeInfoHelper->renderNodeWithPropertiesAndChildrenInformation(
$node,
$actionRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
*/

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface;
use Neos\Neos\FrontendRouting\NodeAddressFactory;
use Neos\Neos\Ui\Domain\Model\AbstractFeedback;
use Neos\Neos\Ui\Domain\Model\FeedbackInterface;
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;
Expand Down Expand Up @@ -111,10 +111,8 @@ public function serializePayload(ControllerContext $controllerContext): array
$contextPath = '';
} else {
$nodeInfoHelper = new NodeInfoHelper();
$contentRepository = $this->contentRepositoryRegistry->get($this->node->contentRepositoryId);
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
$newPreviewUrl = $nodeInfoHelper->createRedirectToNode($this->node, $controllerContext->getRequest());
$contextPath = $nodeAddressFactory->createFromNode($this->node)->serializeForUri();
$contextPath = NodeAddress::fromNode($this->node)->toJson();
}
return [
'newPreviewUrl' => $newPreviewUrl,
Expand Down
Loading

0 comments on commit 13520de

Please sign in to comment.