Skip to content

Commit 3de09ae

Browse files
committed
[TASK] Handle sites without dimensions configured
1 parent 94696fc commit 3de09ae

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Command/NodeIndexCommandController.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,38 @@ public function cleanupCommand() {
205205

206206
/**
207207
* @param string $workspaceName
208+
* @return void
208209
*/
209210
protected function indexWorkspace($workspaceName) {
211+
$combinations = $this->calculateDimensionCombinations();
212+
if ($combinations === array()) {
213+
$this->indexWorkspaceWithDimensions($workspaceName);
214+
} else {
215+
foreach ($combinations as $combination) {
216+
$this->indexWorkspaceWithDimensions($workspaceName, $combination);
217+
}
218+
}
219+
}
210220

211-
foreach ($this->calculateDimensionCombinations() as $combination) {
212-
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $combination));
213-
$rootNode = $context->getRootNode();
221+
/**
222+
* @param string $workspaceName
223+
* @param array $dimensions
224+
* @return void
225+
*/
226+
protected function indexWorkspaceWithDimensions($workspaceName, $dimensions = array()) {
227+
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $dimensions));
228+
$rootNode = $context->getRootNode();
214229

215-
$this->traverseNodes($rootNode);
230+
$this->traverseNodes($rootNode);
216231

217-
$this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($combination) . '" done. (Indexed ' . $this->indexedNodes . ' nodes)');
218-
$this->countedIndexedNodes = $this->countedIndexedNodes + $this->indexedNodes;
219-
$this->indexedNodes = 0;
232+
if ($dimensions === array()) {
233+
$this->outputLine('Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $this->indexedNodes . ' nodes)');
234+
} else {
235+
$this->outputLine('Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $this->indexedNodes . ' nodes)');
220236
}
237+
238+
$this->countedIndexedNodes = $this->countedIndexedNodes + $this->indexedNodes;
239+
$this->indexedNodes = 0;
221240
}
222241

223242
/**

0 commit comments

Comments
 (0)