diff --git a/Neos.Neos/Classes/Domain/NodeLabel/DelegatingNodeLabelRenderer.php b/Neos.Neos/Classes/Domain/NodeLabel/DelegatingNodeLabelRenderer.php index 57f774c4003..fa09e3b0b21 100644 --- a/Neos.Neos/Classes/Domain/NodeLabel/DelegatingNodeLabelRenderer.php +++ b/Neos.Neos/Classes/Domain/NodeLabel/DelegatingNodeLabelRenderer.php @@ -59,10 +59,10 @@ private function getDelegatedGenerator(?NodeType $nodeType): NodeLabelGeneratorI public function getLabel(Node $node): string { return sprintf( - '%s %s', + '%s%s', $node->nodeTypeName->value, $node->name - ? sprintf('(%s)', $node->name->value) + ? sprintf(' (%s)', $node->name->value) : '' ); } diff --git a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php index a48c80385e6..033b5d58863 100644 --- a/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php +++ b/Neos.Neos/Classes/Fusion/Helper/NodeHelper.php @@ -158,11 +158,17 @@ public function nearestContentCollection(Node $node, ?string $nodePath): Node return $node; } else { if ($nodePath === null || $nodePath === '') { + $nodePathOfNode = VisualNodePath::buildFromAncestors( + $node, + $this->contentRepositoryRegistry->get($node->contentRepositoryId), + $this->nodeLabelGenerator + ); throw new Exception(sprintf( - 'No content collection of type %s could be found in the current node and no node path was provided.' + 'No content collection of type %s could be found in the current node (%s) and no node path was provided.' . ' You might want to configure the nodePath property' . ' with a relative path to the content collection.', - $contentCollectionType + $contentCollectionType, + $nodePathOfNode->value ), 1409300545); } $nodePath = NodePath::fromString($nodePath); @@ -173,13 +179,10 @@ public function nearestContentCollection(Node $node, ?string $nodePath): Node if ($subNode !== null && $this->isOfType($subNode, $contentCollectionType)) { return $subNode; } else { - $nodePathOfNode = VisualNodePath::fromAncestors( + $nodePathOfNode = VisualNodePath::buildFromAncestors( $node, - $this->contentRepositoryRegistry->subgraphForNode($node) - ->findAncestorNodes( - $node->aggregateId, - FindAncestorNodesFilter::create() - ) + $this->contentRepositoryRegistry->get($node->contentRepositoryId), + $this->nodeLabelGenerator ); throw new Exception(sprintf( 'No content collection of type %s could be found in the current node (%s) or at the path "%s".' diff --git a/Neos.Neos/Classes/Presentation/VisualNodePath.php b/Neos.Neos/Classes/Presentation/VisualNodePath.php index aaeff1da893..e28180144bb 100644 --- a/Neos.Neos/Classes/Presentation/VisualNodePath.php +++ b/Neos.Neos/Classes/Presentation/VisualNodePath.php @@ -14,11 +14,16 @@ namespace Neos\Neos\Presentation; +use Neos\ContentRepository\Core\ContentRepository; +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindAncestorNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; use Neos\ContentRepository\Core\Projection\ContentGraph\Nodes; +use Neos\Neos\Domain\NodeLabel\NodeLabelGeneratorInterface; /** - * The string-based visual node path, composed of node names and node aggregate IDs as fallback + * The string-based visual node path + * + * @internal helper for enriched debug information */ final readonly class VisualNodePath { @@ -27,13 +32,23 @@ private function __construct( ) { } - public static function fromAncestors(Node $leafNode, Nodes $ancestors): self + public static function buildFromNodes(Nodes $nodes, NodeLabelGeneratorInterface $nodeLabelGenerator): self { $pathSegments = []; - foreach ($ancestors->reverse() as $ancestor) { - $pathSegments[] = $ancestor->name?->value ?: '[' . $ancestor->aggregateId->value . ']'; + foreach ($nodes as $node) { + $pathSegments[] = $nodeLabelGenerator->getLabel($node); } - return new self('/' . implode('/', $pathSegments)); } + + public static function buildFromAncestors(Node $startingNode, ContentRepository $contentRepository, NodeLabelGeneratorInterface $nodeLabelGenerator): self + { + $nodes = $contentRepository->getContentGraph($startingNode->workspaceName) + ->getSubgraph($startingNode->dimensionSpacePoint, $startingNode->visibilityConstraints) + ->findAncestorNodes( + $startingNode->aggregateId, + FindAncestorNodesFilter::create() + )->reverse()->append($startingNode); + return self::buildFromNodes($nodes, $nodeLabelGenerator); + } }