Skip to content

Commit 8e2c09d

Browse files
committed
TASK: Document and validate dimensions input
1 parent 81ea93b commit 8e2c09d

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Classes/Command/SearchCommandController.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public function fulltextCommand(string $searchWord, string $path = '/', ?string
9191
/**
9292
* Prints the index content of the given node identifier.
9393
*
94-
* @param string $identifier
95-
* @param string|null $dimensions
94+
* @param string $identifier The node identifier
95+
* @param string|null $dimensions Dimensions, specified in JSON format, like '{"language":["de"]}'
9696
* @throws Exception
9797
* @throws IllegalObjectTypeException
9898
* @throws QueryBuildingException
@@ -101,6 +101,11 @@ public function fulltextCommand(string $searchWord, string $path = '/', ?string
101101
*/
102102
public function viewNodeCommand(string $identifier, ?string $dimensions = null): void
103103
{
104+
if ($dimensions !== null && is_array(json_decode($dimensions, true)) === false) {
105+
$this->outputLine('<error>Error: </error>The Dimensions must be given as a JSON array like \'{"language":["de"]}\'');
106+
$this->sendAndExit(1);
107+
}
108+
104109
$context = $this->createContext($dimensions);
105110

106111
$queryBuilder = new ElasticSearchQueryBuilder();
@@ -156,6 +161,7 @@ private function createContext(string $dimensions = null): Context
156161
$contextConfiguration = [
157162
'workspaceName' => 'live',
158163
];
164+
159165
if ($dimensions !== null) {
160166
$contextConfiguration['dimensions'] = json_decode($dimensions, true);
161167
}

0 commit comments

Comments
 (0)