diff --git a/src/site/router.php b/src/site/router.php index 13b91d73..1abe8d24 100644 --- a/src/site/router.php +++ b/src/site/router.php @@ -91,21 +91,6 @@ public function __construct($app = null, $menu = null) $router->attachParseRule([$this, 'parseProcessAfter'], Router::PROCESS_AFTER); } - /** - * Allow to set custom segments for routes. - * - * @param string[] $segments - */ - protected function setCustomSegments(array $segments = []) - { - $params = ComponentHelper::getParams('com_osdownloads'); - - // Default values - $default = ['files' => $params->get('route_segment_files') ?: 'files']; - - $this->customSegments = array_merge($default, $segments); - } - /** * Get a list of custom segments. * @@ -113,8 +98,12 @@ protected function setCustomSegments(array $segments = []) */ protected function getCustomSegments(): array { - if (!isset($this->customSegments)) { - $this->setCustomSegments(); + if ($this->customSegments === null) { + $params = ComponentHelper::getParams('com_osdownloads'); + + $this->customSegments = [ + 'files' => $params->get('route_segment_files') ?: 'files' + ]; } return $this->customSegments; @@ -482,10 +471,8 @@ public function parse(&$segments) break; } - if ( - isset($this->customSegments['files']) - && $this->customSegments['files'] === $lastSegment - ) { + $listSegment = $this->getCustomSegments()['files']; + if ($listSegment === $lastSegment) { $vars['view'] = 'downloads'; array_pop($segments);