From 0f909058b31866571c3647d35439a67794fa856e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sun, 16 Jun 2024 18:06:05 +0200 Subject: [PATCH] TASK: Remove `ContentStreamId` from legacy NodeAddress see https://github.com/neos/neos-development-collection/issues/5043 --- .../Classes/FrontendRouting/NodeAddress.php | 21 ++-------- .../FrontendRouting/NodeAddressFactory.php | 40 ++----------------- .../Controller/WorkspaceController.php | 4 +- 3 files changed, 9 insertions(+), 56 deletions(-) diff --git a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php b/Neos.Neos/Classes/FrontendRouting/NodeAddress.php index 0f71cdaa166..08e0d85be27 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeAddress.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeAddress.php @@ -22,16 +22,6 @@ use Neos\Flow\Annotations as Flow; /** - * A persistent, external "address" of a node; used to link to it. - * - * Describes the intention of the user making the current request: - * Show me - * node $nodeAggregateId - * in dimensions $dimensionSpacePoint - * in contentStreamId $contentStreamId - * - * It is used in Neos Routing to build a URI to a node. - * * @deprecated will be removed before Final 9.0 * The NodeAddress was added 6 years ago without the concept of multiple crs * Its usages will be replaced by the new node attached node address @@ -42,8 +32,9 @@ /** * @internal use NodeAddressFactory, if you want to create a NodeAddress */ + /** @phpstan-ignore-next-line its all just temporary */ public function __construct( - public ContentStreamId $contentStreamId, + ?ContentStreamId $_contentStreamId, public DimensionSpacePoint $dimensionSpacePoint, public NodeAggregateId $nodeAggregateId, public WorkspaceName $workspaceName @@ -59,16 +50,10 @@ public function serializeForUri(): string . '__' . $this->nodeAggregateId->value; } - public function isInLiveWorkspace(): bool - { - return $this->workspaceName->isLive(); - } - public function __toString(): string { return sprintf( - 'NodeAddress[contentStream=%s, dimensionSpacePoint=%s, nodeAggregateId=%s, workspaceName=%s]', - $this->contentStreamId->value, + 'NodeAddress[dimensionSpacePoint=%s, nodeAggregateId=%s, workspaceName=%s]', $this->dimensionSpacePoint->toJson(), $this->nodeAggregateId->value, $this->workspaceName->value diff --git a/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php b/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php index 9bc511fdcfe..b5169ae51c1 100644 --- a/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php +++ b/Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php @@ -20,7 +20,6 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress; -use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; /** @@ -38,35 +37,13 @@ public static function create(ContentRepository $contentRepository): self return new self($contentRepository); } - public function createFromContentStreamIdAndDimensionSpacePointAndNodeAggregateId( - ContentStreamId $contentStreamId, - DimensionSpacePoint $dimensionSpacePoint, - NodeAggregateId $nodeAggregateId - ): LegacyNodeAddress { - $workspace = $this->contentRepository->getWorkspaceFinder()->findOneByCurrentContentStreamId( - $contentStreamId - ); - if ($workspace === null) { - throw new \RuntimeException( - 'Cannot build a NodeAddress for traversable node of aggregate ' . $nodeAggregateId->value - . ', because the content stream ' . $contentStreamId->value - . ' is not assigned to a workspace.' - ); - } - return new LegacyNodeAddress( - $contentStreamId, - $dimensionSpacePoint, - $nodeAggregateId, - $workspace->workspaceName, - ); - } - public function createFromNode(Node $node): LegacyNodeAddress { - return $this->createFromContentStreamIdAndDimensionSpacePointAndNodeAggregateId( - $node->subgraphIdentity->contentStreamId, + return new LegacyNodeAddress( + null, $node->dimensionSpacePoint, $node->aggregateId, + $node->workspaceName, ); } @@ -93,17 +70,8 @@ public function createFromUriString(string $serializedNodeAddress): LegacyNodeAd $dimensionSpacePoint = DimensionSpacePoint::fromArray(json_decode(base64_decode($dimensionSpacePointSerialized), true)); $nodeAggregateId = NodeAggregateId::fromString($nodeAggregateIdSerialized); - $contentStreamId = $this->contentRepository->getWorkspaceFinder()->findOneByName($workspaceName) - ?->currentContentStreamId; - if (is_null($contentStreamId)) { - throw new \InvalidArgumentException( - 'Could not resolve content stream identifier for node address ' . $serializedNodeAddress, - 1645363784 - ); - } - return new LegacyNodeAddress( - $contentStreamId, + null, $dimensionSpacePoint, $nodeAggregateId, $workspaceName diff --git a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php index 2ba5e17b7ec..b77ebe018c5 100644 --- a/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php +++ b/Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php @@ -493,7 +493,7 @@ public function rebaseAndRedirectAction(string $targetNode, Workspace $targetWor if ($this->packageManager->isPackageAvailable('Neos.Neos.Ui')) { // todo remove me legacy $legacyTargetNodeAddressInPersonalWorkspace = new LegacyNodeAddress( - $personalWorkspace->currentContentStreamId, + null, $targetNodeAddressInPersonalWorkspace->dimensionSpacePoint, $targetNodeAddressInPersonalWorkspace->aggregateId, $targetNodeAddressInPersonalWorkspace->workspaceName @@ -839,7 +839,7 @@ protected function computeSiteChanges(Workspace $selectedWorkspace, ContentRepos // we can't create `serializedNodeAddress` from the node. // Instead, we use the original stored values. $nodeAddress = new LegacyNodeAddress( - $change->contentStreamId, + null, $change->originDimensionSpacePoint->toDimensionSpacePoint(), $change->nodeAggregateId, $selectedWorkspace->workspaceName