diff --git a/Classes/FlowQueryOperations/SearchOperation.php b/Classes/FlowQueryOperations/SearchOperation.php index 11d2405f0d..f57bb5a1ed 100644 --- a/Classes/FlowQueryOperations/SearchOperation.php +++ b/Classes/FlowQueryOperations/SearchOperation.php @@ -13,6 +13,7 @@ use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter; use Neos\ContentRepository\Core\Projection\ContentGraph\Node; +use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Eel\FlowQuery\FlowQuery; use Neos\Eel\FlowQuery\Operations\AbstractOperation; @@ -72,17 +73,24 @@ public function evaluate(FlowQuery $flowQuery, array $arguments): void /** @var Node $contextNode */ $contextNode = $context[0]; $subgraph = $this->contentRepositoryRegistry->subgraphForNode($contextNode); + $matchingNodeByAggregateId = null; $filter = FindDescendantNodesFilter::create(); if (isset($arguments[0]) && $arguments[0] !== '') { + if ($nodeAggregateId = NodeAggregateId::tryFromString($arguments[0])) { + $matchingNodeByAggregateId = $subgraph->findNodeById($nodeAggregateId); + } $filter = $filter->with(searchTerm: $arguments[0]); } if (isset($arguments[1]) && $arguments[1] !== '') { $filter = $filter->with(nodeTypes: $arguments[1]); } - $nodes = $subgraph->findDescendantNodes( + $nodes = iterator_to_array($subgraph->findDescendantNodes( $contextNode->aggregateId, $filter - ); - $flowQuery->setContext(iterator_to_array($nodes)); + )); + if ($matchingNodeByAggregateId !== null) { + array_unshift($nodes, $matchingNodeByAggregateId); + } + $flowQuery->setContext($nodes); } }