diff --git a/src/Routing/Route/Route.php b/src/Routing/Route/Route.php index 75d1ce141f9..25a11469e03 100644 --- a/src/Routing/Route/Route.php +++ b/src/Routing/Route/Route.php @@ -385,11 +385,8 @@ protected function _parseArgs($args, $context) * @param array $params An array of persistent values to replace persistent ones. * @return array An array with persistent parameters applied. */ - public function persistParams(array $url, array $params) + protected function _persistParams(array $url, array $params) { - if (empty($this->options['persist']) || !is_array($this->options['persist'])) { - return $url; - } foreach ($this->options['persist'] as $persistKey) { if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) { $url[$persistKey] = $params[$persistKey]; @@ -419,7 +416,11 @@ public function match(array $url, array $context = []) $defaults = $this->defaults; $context += ['params' => []]; - $url = $this->persistParams($url, $context['params']); + if (!empty($this->options['persist']) && + is_array($this->options['persist']) + ) { + $url = $this->_persistParams($url, $context['params']); + } unset($context['params']); $hostOptions = array_intersect_key($url, $context);