Skip to content

Commit e394d8d

Browse files
authored
Merge pull request #3858 from neos/task/migrate-to-json-node-address
TASK: migrate to new json node address
2 parents bd4a4b0 + 9c765b7 commit e394d8d

26 files changed

+138
-214
lines changed

Classes/Application/ChangeTargetWorkspace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
namespace Neos\Neos\Ui\Application;
1616

1717
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
18+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1819
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
1920
use Neos\Flow\Annotations as Flow;
20-
use Neos\Neos\FrontendRouting\NodeAddress;
2121

2222
/**
2323
* The application layer level command DTO to communicate the change of the selected target workspace for publication

Classes/Application/ReloadNodes/NodeMap.php

-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414

1515
namespace Neos\Neos\Ui\Application\ReloadNodes;
1616

17-
use Neos\ContentRepository\Core\ContentRepository;
1817
use Neos\Flow\Annotations as Flow;
1918
use Neos\Flow\Mvc\ActionRequest;
20-
use Neos\Neos\FrontendRouting\NodeAddress;
2119
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;
2220

2321
/**

Classes/Application/ReloadNodes/ReloadNodesQueryHandler.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
2020
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
2121
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
22+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
2223
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
2324
use Neos\Flow\Annotations as Flow;
2425
use Neos\Flow\Mvc\ActionRequest;
2526
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
26-
use Neos\Neos\FrontendRouting\NodeAddressFactory;
2727
use Neos\Neos\Ui\Fusion\Helper\NodeInfoHelper;
2828

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

151-
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
152-
153151
return new ReloadNodesQueryResult(
154-
documentId: $nodeAddressFactory->createFromNode($documentNode),
152+
documentId: NodeAddress::fromNode($documentNode),
155153
nodes: $nodeMapBuilder->build()
156154
);
157155
}

Classes/Application/ReloadNodes/ReloadNodesQueryResult.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
namespace Neos\Neos\Ui\Application\ReloadNodes;
1616

17+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1718
use Neos\Flow\Annotations as Flow;
18-
use Neos\Neos\FrontendRouting\NodeAddress;
1919

2020
/**
2121
* The application layer level query result containing all nodes the UI needs
@@ -38,7 +38,7 @@ public function __construct(
3838
public function jsonSerialize(): array
3939
{
4040
return [
41-
'documentId' => $this->documentId->serializeForUri(),
41+
'documentId' => $this->documentId->toJson(),
4242
'nodes' => $this->nodes
4343
];
4444
}

Classes/ContentRepository/Service/NeosUiNodeService.php

+5-16
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,30 @@
1212
*/
1313

1414

15-
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
1615
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
17-
use Neos\Neos\FrontendRouting\NodeAddressFactory;
1816
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
17+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1918
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
2019
use Neos\Flow\Annotations as Flow;
21-
use Neos\Neos\FrontendRouting\NodeAddress;
22-
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;
2320

2421
/**
2522
* @internal
2623
* @Flow\Scope("singleton")
2724
*/
2825
class NeosUiNodeService
2926
{
30-
use NodeTypeWithFallbackProvider;
31-
3227
#[Flow\Inject]
3328
protected ContentRepositoryRegistry $contentRepositoryRegistry;
3429

35-
public function findNodeBySerializedNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): ?Node
30+
public function findNodeBySerializedNodeAddress(string $serializedNodeAddress): ?Node
3631
{
37-
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
38-
$nodeAddress = NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
32+
$nodeAddress = NodeAddress::fromJsonString($serializedNodeAddress);
33+
$contentRepository = $this->contentRepositoryRegistry->get($nodeAddress->contentRepositoryId);
3934

4035
$subgraph = $contentRepository->getContentGraph($nodeAddress->workspaceName)->getSubgraph(
4136
$nodeAddress->dimensionSpacePoint,
4237
VisibilityConstraints::withoutRestrictions()
4338
);
44-
return $subgraph->findNodeById($nodeAddress->nodeAggregateId);
45-
}
46-
47-
public function deserializeNodeAddress(string $serializedNodeAddress, ContentRepositoryId $contentRepositoryId): NodeAddress
48-
{
49-
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
50-
return NodeAddressFactory::create($contentRepository)->createFromUriString($serializedNodeAddress);
39+
return $subgraph->findNodeById($nodeAddress->aggregateId);
5140
}
5241
}

Classes/ContentRepository/Service/WorkspaceService.php

+13-16
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindClosestNodeFilter;
1515
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
1616
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
17+
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
1718
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
1819
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
1920
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
2021
use Neos\Flow\Annotations as Flow;
2122
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
2223
use Neos\Neos\Domain\Service\WorkspacePublishingService;
23-
use Neos\Neos\FrontendRouting\NodeAddress;
24-
use Neos\Neos\FrontendRouting\NodeAddressFactory;
2524
use Neos\Neos\PendingChangesProjection\Change;
2625
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;
2726

@@ -57,26 +56,26 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
5756
$unpublishedNodes = [];
5857
foreach ($pendingChanges as $change) {
5958
if ($change->removalAttachmentPoint) {
60-
$nodeAddress = new NodeAddress(
61-
$change->contentStreamId,
59+
$nodeAddress = NodeAddress::create(
60+
$contentRepositoryId,
61+
$workspaceName,
6262
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
63-
$change->nodeAggregateId,
64-
$workspaceName
63+
$change->nodeAggregateId
6564
);
6665

6766
/**
6867
* See {@see Remove::apply} -> Removal Attachment Point == closest document node.
6968
*/
70-
$documentNodeAddress = new NodeAddress(
71-
$change->contentStreamId,
69+
$documentNodeAddress = NodeAddress::create(
70+
$contentRepositoryId,
71+
$workspaceName,
7272
$change->originDimensionSpacePoint->toDimensionSpacePoint(),
73-
$change->removalAttachmentPoint,
74-
$workspaceName
73+
$change->removalAttachmentPoint
7574
);
7675

7776
$unpublishedNodes[] = [
78-
'contextPath' => $nodeAddress->serializeForUri(),
79-
'documentContextPath' => $documentNodeAddress->serializeForUri(),
77+
'contextPath' => $nodeAddress->toJson(),
78+
'documentContextPath' => $documentNodeAddress->toJson(),
8079
'typeOfChange' => $this->getTypeOfChange($change)
8180
];
8281
} else {
@@ -89,11 +88,9 @@ public function getPublishableNodeInfo(WorkspaceName $workspaceName, ContentRepo
8988
if ($node instanceof Node) {
9089
$documentNode = $subgraph->findClosestNode($node->aggregateId, FindClosestNodeFilter::create(nodeTypes: NodeTypeNameFactory::NAME_DOCUMENT));
9190
if ($documentNode instanceof Node) {
92-
$nodeAddressFactory = NodeAddressFactory::create($contentRepository);
9391
$unpublishedNodes[] = [
94-
'contextPath' => $nodeAddressFactory->createFromNode($node)->serializeForUri(),
95-
'documentContextPath' => $nodeAddressFactory->createFromNode($documentNode)
96-
->serializeForUri(),
92+
'contextPath' => NodeAddress::fromNode($node)->toJson(),
93+
'documentContextPath' => NodeAddress::fromNode($documentNode)->toJson(),
9794
'typeOfChange' => $this->getTypeOfChange($change)
9895
];
9996
}

Classes/Controller/BackendController.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Neos\Neos\Domain\Repository\SiteRepository;
2424
use Neos\Neos\Domain\Service\NodeTypeNameFactory;
2525
use Neos\Neos\Domain\Service\WorkspaceService;
26-
use Neos\Neos\FrontendRouting\NodeAddressFactory;
2726
use Neos\Neos\FrontendRouting\NodeUriBuilderFactory;
2827
use Neos\Neos\FrontendRouting\SiteDetection\SiteDetectionResult;
2928
use Neos\Neos\Service\UserService;
@@ -136,7 +135,7 @@ public function indexAction(string $node = null)
136135
$siteDetectionResult = SiteDetectionResult::fromRequest($this->request->getHttpRequest());
137136
$contentRepository = $this->contentRepositoryRegistry->get($siteDetectionResult->contentRepositoryId);
138137

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

142141
if ($user === null) {
@@ -180,7 +179,7 @@ public function indexAction(string $node = null)
180179
if (!$nodeAddress) {
181180
$node = $siteNode;
182181
} else {
183-
$node = $subgraph->findNodeById($nodeAddress->nodeAggregateId);
182+
$node = $subgraph->findNodeById($nodeAddress->aggregateId);
184183
}
185184

186185
$this->view->setOption('title', 'Neos CMS');

0 commit comments

Comments
 (0)