Skip to content

Commit

Permalink
TASK: Remove ContentStreamId from legacy NodeAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jun 16, 2024
1 parent 931304f commit 0f90905
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 56 deletions.
21 changes: 3 additions & 18 deletions Neos.Neos/Classes/FrontendRouting/NodeAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
40 changes: 4 additions & 36 deletions Neos.Neos/Classes/FrontendRouting/NodeAddressFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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,
);
}

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Neos.Workspace.Ui/Classes/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0f90905

Please sign in to comment.