Skip to content

Commit b91644e

Browse files
author
Rens Admiraal
committed
BUGFIX: Remove unneeded depency on Neos
The NodeIndexCommandController used a trait from Neos which adds just little value while adding a strong dependency to Neos which conflicts with the content repository requirement to run 'standalone'.
1 parent ca20f64 commit b91644e

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

Classes/Command/NodeIndexCommandController.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313

1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait;
16+
use Neos\ContentRepository\Domain\Service\Context;
17+
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
1618
use Neos\Flow\Annotations as Flow;
1719
use Neos\Flow\Cli\CommandController;
18-
use Neos\Neos\Controller\CreateContentContextTrait;
1920
use Neos\ContentRepository\Domain\Model\Workspace;
2021

2122
/**
@@ -26,7 +27,6 @@
2627
class NodeIndexCommandController extends CommandController
2728
{
2829
use IndexWorkspaceTrait;
29-
use CreateContentContextTrait;
3030

3131
/**
3232
* @Flow\Inject
@@ -76,6 +76,12 @@ class NodeIndexCommandController extends CommandController
7676
*/
7777
protected $configurationManager;
7878

79+
/**
80+
* @Flow\Inject
81+
* @var ContextFactoryInterface
82+
*/
83+
protected $contextFactory;
84+
7985
/**
8086
* @var array
8187
*/
@@ -273,4 +279,30 @@ public function cleanupCommand()
273279
$this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s: %s"', $response->status, $response->error->type, $response->error->reason));
274280
}
275281
}
282+
283+
/**
284+
* Create a ContentContext based on the given workspace name
285+
*
286+
* @param string $workspaceName Name of the workspace to set for the context
287+
* @param array $dimensions Optional list of dimensions and their values which should be set
288+
* @return Context
289+
*/
290+
protected function createContentContext($workspaceName, array $dimensions = array())
291+
{
292+
$contextProperties = array(
293+
'workspaceName' => $workspaceName,
294+
'invisibleContentShown' => true,
295+
'inaccessibleContentShown' => true
296+
);
297+
298+
if ($dimensions !== array()) {
299+
$contextProperties['dimensions'] = $dimensions;
300+
$contextProperties['targetDimensions'] = array_map(function ($dimensionValues) {
301+
return array_shift($dimensionValues);
302+
}, $dimensions);
303+
}
304+
305+
return $this->contextFactory->create($contextProperties);
306+
}
307+
276308
}

0 commit comments

Comments
 (0)