Skip to content

Commit

Permalink
Merge pull request #10 from belliconag/supportEmptySegmentForDimensio…
Browse files Browse the repository at this point in the history
…ns-false-fix

BUGFIX: Gracefully handle URLs without (correct) dimensions
  • Loading branch information
kdambekalns authored May 2, 2017
2 parents b5fcfc8 + fc3f59f commit 99c81fb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Classes/MOC/NotFound/ViewHelpers/RequestViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ protected function appendFirstUriPartIfValidDimension(&$path) {
}
} else {
if (count($firstUriPartExploded) !== count($dimensionPresets)) {
$this->appendDefaultDimensionPresetUriSegments($dimensionPresets, $path);
return;
}
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$uriSegment = array_shift($firstUriPartExploded);
$preset = $this->contentDimensionPresetSource->findPresetByUriSegment($dimensionName, $uriSegment);
if ($preset === null) {
$this->appendDefaultDimensionPresetUriSegments($dimensionPresets, $path);
return;
}
}
Expand All @@ -149,4 +151,16 @@ protected function appendFirstUriPartIfValidDimension(&$path) {
$path = $matches['firstUriPart'] . '/' . $path;
}

/**
* @param array $dimensionPresets
* @param string $path
* @return void
*/
protected function appendDefaultDimensionPresetUriSegments(array $dimensionPresets, &$path) {
$defaultDimensionPresetUriSegments = [];
foreach ($dimensionPresets as $dimensionName => $dimensionPreset) {
$defaultDimensionPresetUriSegments[] = $dimensionPreset['presets'][$dimensionPreset['defaultPreset']]['uriSegment'];
}
$path = implode('_', $defaultDimensionPresetUriSegments) . '/' . $path;
}
}

0 comments on commit 99c81fb

Please sign in to comment.