diff --git a/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php b/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php index 6ae81fc3cc1..695f73ab566 100644 --- a/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php +++ b/Neos.ContentRepository/Classes/Domain/Model/ExpressionBasedNodeLabelGenerator.php @@ -66,7 +66,7 @@ public function initializeObject() } /** - * Render a node label + * Render a node label based on an eel expression or return the expression if it is not valid eel. * * @param \Neos\ContentRepository\Domain\Projection\Content\NodeInterface $node * @return string @@ -74,6 +74,9 @@ public function initializeObject() */ public function getLabel(\Neos\ContentRepository\Domain\Projection\Content\NodeInterface $node): string { + if (Utility::parseEelExpression($this->getExpression()) === null) { + return $this->getExpression(); + } return (string)Utility::evaluateEelExpression($this->getExpression(), $this->eelEvaluator, ['node' => $node], $this->defaultContextConfiguration); } } diff --git a/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml b/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml index 395d476dd84..56362f49579 100644 --- a/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml +++ b/Neos.ContentRepository/Configuration/Testing/NodeTypes.yaml @@ -199,3 +199,9 @@ type: string someDate: type: DateTime + +'Neos.ContentRepository.Testing:NodeTypeWithPlainLabel': + label: 'Test nodetype' + +'Neos.ContentRepository.Testing:NodeTypeWithEelExpressionLabel': + label: '${"Test" + " " + "nodetype"}' diff --git a/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php b/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php index d34d6f52fe8..cceb456f964 100644 --- a/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php +++ b/Neos.ContentRepository/Tests/Functional/Domain/NodesTest.php @@ -1060,6 +1060,23 @@ public function getLabelUsesFallbackExpression() self::assertEquals('unstructured ()', $node->getLabel()); } + /** + * @test + */ + public function getLabelReturnsParsedEelExpressionOrFallback() + { + $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); + $nodeTypeWithPlainLabel = $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithPlainLabel'); + $nodeTypeWithEelExpressionLabel = $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithEelExpressionLabel'); + + $rootNode = $this->context->getNode('/'); + $nodeWithPlainLabel = $rootNode->createNode('node-plain', $nodeTypeWithPlainLabel, '30e893c1-caef-0ca5-b53d-e5699bb8e506'); + $nodeWithEelExpressionLabel = $rootNode->createNode('node-eel', $nodeTypeWithEelExpressionLabel, '81c848ed-abb5-7608-a5db-7eea0331ccfa'); + + self::assertEquals('Test nodetype', $nodeWithPlainLabel->getLabel()); + self::assertEquals('Test nodetype', $nodeWithEelExpressionLabel->getLabel()); + } + /** * @test */ diff --git a/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php b/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php index 7c4193a395b..ae5851f639f 100644 --- a/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php +++ b/Neos.ContentRepository/Tests/Unit/Domain/Model/NodeDataTest.php @@ -371,7 +371,7 @@ function ($name) { self::assertEquals('unstructured', $this->nodeData->getNodeType()->getName()); - $myNodeType = $mockNodeTypeManager->getNodeType('typo3:mycontent'); + $myNodeType = $mockNodeTypeManager->getNodeType('neos:mycontent'); $this->nodeData->setNodeType($myNodeType); self::assertEquals($myNodeType, $this->nodeData->getNodeType()); }