/** * @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $currentNode * @return void */ protected function traverseNodes(\TYPO3\TYPO3CR\Domain\Model\NodeInterface $currentNode) { if ($this->limit !== NULL && $this->indexedNodes > $this->limit) { return; } $this->nodeIndexingManager->indexNode($currentNode); $this->indexedNodes++; foreach ($currentNode->getChildNodes() as $childNode) { $this->traverseNodes($childNode); } }
/** * @param string $workspaceName * @param array $dimensions * @param integer $limit * @param callable $callback * @return integer */ protected function indexWorkspaceWithDimensions($workspaceName, array $dimensions = [], $limit = null, callable $callback = null) { $context = $this->contextFactory->create(['workspaceName' => $workspaceName, 'dimensions' => $dimensions]); $rootNode = $context->getRootNode(); $indexedNodes = 0; $traverseNodes = function (NodeInterface $currentNode, &$indexedNodes) use($limit, &$indexedNodes, &$traverseNodes) { if ($limit !== null && $indexedNodes > $limit) { return; } $this->nodeIndexingManager->indexNode($currentNode); $indexedNodes++; array_map(function (NodeInterface $childNode) use($traverseNodes, &$indexedNodes) { $traverseNodes($childNode, $indexedNodes); }, $currentNode->getChildNodes()); }; $traverseNodes($rootNode, $indexedNodes); if ($callback !== null) { $callback($workspaceName, $indexedNodes, $dimensions); } return $indexedNodes; }