protected function parseDimensionsAndNodePathFromRequestPathAllowingEmptySegment(&$requestPath)
{
$dimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
if (count($dimensionPresets) === 0) {
return [];
}
$dimensionsAndDimensionValues = [];
$chosenDimensionPresets = [];
$matches = [];
preg_match(self::DIMENSION_REQUEST_PATH_MATCHER, $requestPath, $matches);
$firstUriPartIsValidDimension = true;
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$dimensionsAndDimensionValues[$dimensionName] = $dimensionPreset['presets'][$dimensionPreset['defaultPreset']]['values'];
$chosenDimensionPresets[$dimensionName] = $dimensionPreset['defaultPreset'];
}
if (isset($matches['firstUriPart'])) {
$firstUriPartExploded = explode('_', $matches['firstUriPart']);
foreach ($firstUriPartExploded as $uriSegment) {
$uriSegmentIsValid = false;
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment);
if ($preset !== null) {
$uriSegmentIsValid = true;
$dimensionsAndDimensionValues[$dimensionName] = $preset['values'];
$chosenDimensionPresets[$dimensionName] = $preset['identifier'];
break;
}
}
if (!$uriSegmentIsValid) {
$firstUriPartIsValidDimension = false;
break;
}
}
if ($firstUriPartIsValidDimension) {
$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))), 1428657721);
}
return $dimensionsAndDimensionValues;
}