Skip to content

Commit

Permalink
TASK: Remove node:// protocol handling from NodeAddressNormalizer
Browse files Browse the repository at this point in the history
That was also not in 8.3 supported in the linking service or Neos.Neos:NodeUri
  • Loading branch information
mhsdesign committed Oct 11, 2024
1 parent 38f6834 commit 22993c5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
1 change: 0 additions & 1 deletion Neos.Neos/Classes/Utility/LegacyNodePathNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ final class LegacyNodePathNormalizer
*
* The following syntax is not implemented and handled here:
*
* - node://my-node-identifier
* - /<Neos.Neos:Sites>/my-site/main
* - some/relative/path
*
Expand Down
10 changes: 2 additions & 8 deletions Neos.Neos/Classes/Utility/NodeAddressNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\NodePath;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;

Expand All @@ -22,10 +21,11 @@ final class NodeAddressNormalizer
*
* Following string syntax is allowed, as well as passing a NodePath or AbsoluteNodePath value object:
*
* - node://my-node-identifier
* - /<Neos.Neos:Sites>/my-site/main
* - some/relative/path
*
* The node protocol node://my-node-identifier is not handled here.
*
* The following legacy syntax is not implemented and handled here:
*
* - /sites/site/absolute/path
Expand All @@ -42,12 +42,6 @@ public function resolveNodeAddressFromPath(AbsoluteNodePath|NodePath|string $pat
throw new \RuntimeException('Empty strings can not be resolved to nodes.', 1719999872);
}

if (is_string($path) && str_starts_with($path, 'node://')) {
return NodeAddress::fromNode($baseNode)->withAggregateId(
NodeAggregateId::fromString(substr($path, strlen('node://')))
);
}

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($baseNode);

if (is_string($path) && AbsoluteNodePath::patternIsMatchedByString($path)) {
Expand Down
17 changes: 12 additions & 5 deletions Neos.Neos/Classes/ViewHelpers/Link/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Log\ThrowableStorageInterface;
Expand Down Expand Up @@ -256,11 +257,17 @@ public function render(): string
), 1719953186);
}

$possibleAbsoluteNodePath = $this->legacyNodePathNormalizer->tryResolveLegacyPathSyntaxToAbsoluteNodePath($node, $baseNode);
$nodeAddress = $this->nodeAddressNormalizer->resolveNodeAddressFromPath(
$possibleAbsoluteNodePath ?? $node,
$baseNode
);
if (str_starts_with($node, 'node://')) {
$nodeAddress = NodeAddress::fromNode($baseNode)->withAggregateId(
NodeAggregateId::fromString(substr($node, strlen('node://')))
);
} else {
$possibleAbsoluteNodePath = $this->legacyNodePathNormalizer->tryResolveLegacyPathSyntaxToAbsoluteNodePath($node, $baseNode);
$nodeAddress = $this->nodeAddressNormalizer->resolveNodeAddressFromPath(
$possibleAbsoluteNodePath ?? $node,
$baseNode
);
}

$subgraph = $this->contentRepositoryRegistry->subgraphForNode($baseNode);
$resolvedNode = $subgraph->findNodeById($nodeAddress->aggregateId);
Expand Down
17 changes: 12 additions & 5 deletions Neos.Neos/Classes/ViewHelpers/Uri/NodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAddress;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Log\ThrowableStorageInterface;
Expand Down Expand Up @@ -200,11 +201,17 @@ public function render(): string
), 1719953186);
}

$possibleAbsoluteNodePath = $this->legacyNodePathNormalizer->tryResolveLegacyPathSyntaxToAbsoluteNodePath($node, $baseNode);
$nodeAddress = $this->nodeAddressNormalizer->resolveNodeAddressFromPath(
$possibleAbsoluteNodePath ?? $node,
$baseNode
);
if (str_starts_with($node, 'node://')) {
$nodeAddress = NodeAddress::fromNode($baseNode)->withAggregateId(
NodeAggregateId::fromString(substr($node, strlen('node://')))
);
} else {
$possibleAbsoluteNodePath = $this->legacyNodePathNormalizer->tryResolveLegacyPathSyntaxToAbsoluteNodePath($node, $baseNode);
$nodeAddress = $this->nodeAddressNormalizer->resolveNodeAddressFromPath(
$possibleAbsoluteNodePath ?? $node,
$baseNode
);
}
} elseif ($node instanceof Node) {
$nodeAddress = NodeAddress::fromNode($node);
} else {
Expand Down
4 changes: 0 additions & 4 deletions Neos.Neos/Tests/Behavior/Features/Fusion/NodeUri.feature
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,12 @@ Feature: Tests for the "Neos.Neos:NodeUri" Fusion prototype
relativePath = Neos.Neos:NodeUri {
node = 'a1'
}
nodeIdentifier = Neos.Neos:NodeUri {
node = 'node://a1'
}
}
"""
Then I expect the following Fusion rendering result:
"""
sitesRootPath: /a1
relativePath: /a1
nodeIdentifier: /a1
"""

Scenario: Node as legacy string node path syntax
Expand Down

0 comments on commit 22993c5

Please sign in to comment.