protected function getContextForProperties(array $humanReadableContextProperties, $addDimensionDefaults = false) { if ($this->isolated === true) { $this->callStepInSubProcess(__METHOD__, sprintf(' %s %s %s %s', 'string', escapeshellarg($humanReadableContextProperties), 'integer', escapeshellarg($addDimensionDefaults))); } else { /** @var \Neos\ContentRepository\Domain\Service\ContextFactoryInterface $contextFactory */ $contextFactory = $this->getObjectManager()->get(\Neos\ContentRepository\Domain\Service\ContextFactoryInterface::class); $contextProperties = array(); if (isset($humanReadableContextProperties['Language'])) { $contextProperties['dimensions']['language'] = Arrays::trimExplode(',', $humanReadableContextProperties['Language']); } if (isset($humanReadableContextProperties['Workspace'])) { $contextProperties['workspaceName'] = $humanReadableContextProperties['Workspace']; $this->createWorkspaceIfNeeded($contextProperties['workspaceName']); } else { $this->createWorkspaceIfNeeded(); } if (isset($humanReadableContextProperties['Hidden'])) { $contextProperties['hidden'] = $humanReadableContextProperties['Hidden']; } foreach ($humanReadableContextProperties as $propertyName => $propertyValue) { // Set flexible dimensions from features if (strpos($propertyName, 'Dimension: ') === 0) { $contextProperties['dimensions'][substr($propertyName, strlen('Dimension: '))] = Arrays::trimExplode(',', $propertyValue); } // FIXME We lack a good API to manipulate dimension values explicitly or assign multiple values, so we are doing this via target dimension values if (strpos($propertyName, 'Target dimension: ') === 0) { if ($propertyValue === '') { $propertyValue = null; } $contextProperties['targetDimensions'][substr($propertyName, strlen('Target dimension: '))] = $propertyValue; } } if ($addDimensionDefaults) { $contentDimensionRepository = $this->getObjectManager()->get(\Neos\ContentRepository\Domain\Repository\ContentDimensionRepository::class); $availableDimensions = $contentDimensionRepository->findAll(); foreach ($availableDimensions as $dimension) { if (isset($contextProperties['dimensions'][$dimension->getIdentifier()]) && !in_array($dimension->getDefault(), $contextProperties['dimensions'][$dimension->getIdentifier()])) { $contextProperties['dimensions'][$dimension->getIdentifier()][] = $dimension->getDefault(); } } } $contextProperties['invisibleContentShown'] = true; return $contextFactory->create($contextProperties); } }