diff --git a/src/Router.php b/src/Router.php index 7358ed1..03fdd4c 100644 --- a/src/Router.php +++ b/src/Router.php @@ -107,6 +107,11 @@ public static function match(string $methods, string $pattern, $handler) 'namespace' => null, ]; + list($handler, $routeOptions) = static::mapHandler( + $handler, + $routeOptions + ); + if (is_string($handler)) { $namespace = static::$namespace; @@ -119,11 +124,6 @@ public static function match(string $methods, string $pattern, $handler) static::$namespace = $namespace; } - list($handler, $routeOptions) = static::mapHandler( - $handler, - $routeOptions - ); - foreach (explode('|', $methods) as $method) { static::$routes[$method][] = [ 'pattern' => $pattern, diff --git a/src/Router/Core.php b/src/Router/Core.php index ec5fccc..fb98853 100644 --- a/src/Router/Core.php +++ b/src/Router/Core.php @@ -171,19 +171,6 @@ protected static function mapHandler($handler, $options): array || is_numeric($key) && is_string($value) && strpos($value, '@') ) { $handler = $handler[$key]; - - if (is_string($handler)) { - $namespace = static::$namespace; - - if ($options['namespace']) { - static::$namespace = $options['namespace']; - } - - $handler = str_replace('\\\\', '\\', static::$namespace . "\\$handler"); - - static::$namespace = $namespace; - } - unset($handlerData[$key]); break; }