Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Find nodes by their id in Neos Backend #3789

Open
wants to merge 7 commits into
base: 9.0
Choose a base branch
from
18 changes: 11 additions & 7 deletions Classes/FlowQueryOperations/SearchOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\Projection\ContentGraph\SearchTerm;
use Neos\ContentRepository\Core\NodeType\NodeTypeConstraintParser;
use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\NodeType\NodeTypeCriteria;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateIds;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Eel\FlowQuery\Operations\AbstractOperation;
Expand Down Expand Up @@ -76,17 +73,24 @@ public function evaluate(FlowQuery $flowQuery, array $arguments): void
/** @var Node $contextNode */
$contextNode = $context[0];
$subgraph = $this->contentRepositoryRegistry->subgraphForNode($contextNode);
$matchingNodeByAggregateId = [];
bwaidelich marked this conversation as resolved.
Show resolved Hide resolved
$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);
}
}
Loading