protected function parseDimensionsAndNodePathFromRequestPathAllowingNonUniqueSegment(&$requestPath)
{
$dimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
if (count($dimensionPresets) === 0) {
return [];
}
$dimensionsAndDimensionValues = [];
$chosenDimensionPresets = [];
$matches = [];
preg_match(self::DIMENSION_REQUEST_PATH_MATCHER, $requestPath, $matches);
if (!isset($matches['firstUriPart'])) {
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$dimensionsAndDimensionValues[$dimensionName] = $dimensionPreset['presets'][$dimensionPreset['defaultPreset']]['values'];
$chosenDimensionPresets[$dimensionName] = $dimensionPreset['defaultPreset'];
}
} else {
$firstUriPart = explode('_', $matches['firstUriPart']);
if (count($firstUriPart) !== count($dimensionPresets)) {
throw new InvalidRequestPathException(sprintf('The first path segment of the request URI (%s) does not contain the necessary content dimension preset identifiers for all configured dimensions. This might be an old URI which doesn\'t match the current dimension configuration anymore.', $requestPath), 1413389121);
}
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$uriSegment = array_shift($firstUriPart);
$preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment);
if ($preset === null) {
throw new NoSuchDimensionValueException(sprintf('Could not find a preset for content dimension "%s" through the given URI segment "%s".', $dimensionName, $uriSegment), 1413389321);
}
$dimensionsAndDimensionValues[$dimensionName] = $preset['values'];
$chosenDimensionPresets[$dimensionName] = $preset['identifier'];
}
$requestPath = isset($matches['remainingRequestPath']) ? $matches['remainingRequestPath'] : '';
}
if (!$this->contentDimensionPresetSource->isPresetCombinationAllowedByConstraints($chosenDimensionPresets)) {
throw new InvalidDimensionPresetCombinationException(sprintf('The resolved content dimension preset combination (%s) is invalid or restricted by content dimension constraints. Check your content dimension settings if you think that this is an error.', implode(', ', array_keys($chosenDimensionPresets))), 1462175794805);
}
return $dimensionsAndDimensionValues;
}