From 654ee210345d380c6667f227331312df5a7574d2 Mon Sep 17 00:00:00 2001 From: Virgil-Adrian Teaca Date: Sun, 10 Apr 2016 12:32:43 +0200 Subject: [PATCH] Support the Deep Grouping into Routing --- system/Core/Router.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/system/Core/Router.php b/system/Core/Router.php index 05550c0fc9..a8d0599fc7 100644 --- a/system/Core/Router.php +++ b/system/Core/Router.php @@ -222,23 +222,27 @@ public function addRoute($method, $route, $callback = null) $pattern = ltrim($route, '/'); if (! empty(self::$routeGroups)) { - $prefixes = array(); + $parts = array(); $namespace = ''; foreach (self::$routeGroups as $group) { // Add the current prefix to the prefixes list. - array_push($prefixes, $group['prefix']); + array_push($parts, $group['prefix']); // Keep always the last Controller's namespace. $namespace = $group['namespace']; } + if (! empty($pattern)) { + array_push($parts, $pattern); + } + // Adjust the Route PATTERN. - if(! empty($prefixes)) { - $pattern = implode('/', $prefixes) .'/' .$pattern; + if (! empty($parts)) { + $pattern = implode('/', $parts); } // Adjust the Route CALLBACK, when it is not a Closure. - if(! empty($namespace) && ! is_object($callback)) { + if (! empty($namespace) && ! is_object($callback)) { $callback = $namespace .'\\' .$callback; } }