|
14 | 14 | */
|
15 | 15 |
|
16 | 16 | use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
|
17 |
| -use Neos\ContentRepository\Core\NodeType\NodeTypeName; |
18 |
| -use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindChildNodesFilter; |
19 |
| -use Neos\ContentRepository\Core\Projection\ContentGraph\Node; |
20 |
| -use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints; |
| 17 | +use Neos\ContentRepository\Core\Projection\ContentGraph\Filter\FindDescendantNodesFilter; |
21 | 18 | use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
|
22 | 19 | use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
|
23 | 20 | use Neos\ContentRepository\Search\Indexer\NodeIndexingManager;
|
24 | 21 | use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
|
25 | 22 | use Neos\Flow\Annotations as Flow;
|
| 23 | +use Neos\Neos\Domain\Service\NodeTypeNameFactory; |
| 24 | +use Neos\Neos\Domain\SubtreeTagging\NeosVisibilityConstraints; |
26 | 25 |
|
27 | 26 | /**
|
28 | 27 | * Workspace Indexer for Content Repository Nodes.
|
@@ -73,27 +72,27 @@ public function index(ContentRepositoryId $contentRepositoryId, WorkspaceName $w
|
73 | 72 | public function indexWithDimensions(ContentRepositoryId $contentRepositoryId, WorkspaceName $workspaceName, DimensionSpacePoint $dimensionSpacePoint, ?int $limit = null, ?callable $callback = null): int
|
74 | 73 | {
|
75 | 74 | $contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
|
| 75 | + $contentGraph = $contentRepository->getContentGraph($workspaceName); |
| 76 | + |
| 77 | + $rootNodeAggregate = $contentGraph->findRootNodeAggregateByType(NodeTypeNameFactory::forSites()); |
| 78 | + $subgraph = $contentGraph->getSubgraph($dimensionSpacePoint, NeosVisibilityConstraints::excludeRemoved()); |
76 | 79 |
|
77 |
| - $rootNodeAggregate = $contentRepository->getContentGraph($workspaceName)->findRootNodeAggregateByType(NodeTypeName::fromString('Neos.Neos:Sites')); |
78 |
| - $subgraph = $contentRepository->getContentGraph($workspaceName)->getSubgraph($dimensionSpacePoint, VisibilityConstraints::withoutRestrictions()); |
79 | 80 | $rootNode = $subgraph->findNodeById($rootNodeAggregate->nodeAggregateId);
|
80 | 81 | $indexedNodes = 0;
|
81 | 82 |
|
82 |
| - $traverseNodes = function (Node $currentNode, &$indexedNodes) use ($subgraph, $limit, &$traverseNodes) { |
| 83 | + $this->nodeIndexingManager->indexNode($rootNode); |
| 84 | + $indexedNodes++; |
| 85 | + |
| 86 | + foreach ($subgraph->findDescendantNodes($rootNode->aggregateId, FindDescendantNodesFilter::create()) as $descendantNode) { |
83 | 87 | if ($limit !== null && $indexedNodes > $limit) {
|
84 |
| - return; |
| 88 | + break; |
85 | 89 | }
|
86 | 90 |
|
87 |
| - $this->nodeIndexingManager->indexNode($currentNode); |
| 91 | + $this->nodeIndexingManager->indexNode($descendantNode); |
88 | 92 | $indexedNodes++;
|
89 | 93 |
|
90 |
| - array_map(function (Node $childNode) use ($traverseNodes, &$indexedNodes) { |
91 |
| - $traverseNodes($childNode, $indexedNodes); |
92 |
| - }, iterator_to_array($subgraph->findChildNodes($currentNode->aggregateId, FindChildNodesFilter::create())->getIterator())); |
93 | 94 | };
|
94 | 95 |
|
95 |
| - $traverseNodes($rootNode, $indexedNodes); |
96 |
| - |
97 | 96 | $this->nodeIndexingManager->flushQueues();
|
98 | 97 |
|
99 | 98 | if ($callback !== null) {
|
|
0 commit comments