|
13 | 13 |
|
14 | 14 | use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Mapping\NodeTypeMappingBuilder; |
15 | 15 | use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Service\IndexWorkspaceTrait; |
| 16 | +use Neos\ContentRepository\Domain\Service\Context; |
| 17 | +use Neos\ContentRepository\Domain\Service\ContextFactoryInterface; |
16 | 18 | use Neos\Flow\Annotations as Flow; |
17 | 19 | use Neos\Flow\Cli\CommandController; |
18 | | -use Neos\Neos\Controller\CreateContentContextTrait; |
19 | 20 | use Neos\ContentRepository\Domain\Model\Workspace; |
20 | 21 |
|
21 | 22 | /** |
|
26 | 27 | class NodeIndexCommandController extends CommandController |
27 | 28 | { |
28 | 29 | use IndexWorkspaceTrait; |
29 | | - use CreateContentContextTrait; |
30 | 30 |
|
31 | 31 | /** |
32 | 32 | * @Flow\Inject |
@@ -76,6 +76,12 @@ class NodeIndexCommandController extends CommandController |
76 | 76 | */ |
77 | 77 | protected $configurationManager; |
78 | 78 |
|
| 79 | + /** |
| 80 | + * @Flow\Inject |
| 81 | + * @var ContextFactoryInterface |
| 82 | + */ |
| 83 | + protected $contextFactory; |
| 84 | + |
79 | 85 | /** |
80 | 86 | * @var array |
81 | 87 | */ |
@@ -273,4 +279,30 @@ public function cleanupCommand() |
273 | 279 | $this->logger->log(sprintf('Nothing removed. ElasticSearch responded with status %s, saying "%s: %s"', $response->status, $response->error->type, $response->error->reason)); |
274 | 280 | } |
275 | 281 | } |
| 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 = []) |
| 291 | + { |
| 292 | + $contextProperties = [ |
| 293 | + 'workspaceName' => $workspaceName, |
| 294 | + 'invisibleContentShown' => true, |
| 295 | + 'inaccessibleContentShown' => true |
| 296 | + ]; |
| 297 | + |
| 298 | + if ($dimensions !== []) { |
| 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 | + |
276 | 308 | } |
0 commit comments