Skip to content

Commit

Permalink
fix: patch up namespace issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Jun 3, 2023
1 parent ce092ed commit 0a14f6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Router.php
Expand Up @@ -143,6 +143,7 @@ public static function match(string $methods, string $pattern, $handler)
static::$namedRoutes[$routeOptions['name']] = $pattern;
}


if ($routeOptions['middleware']) {
static::before($methods, $rawPattern, $routeOptions['middleware']);
}
Expand Down
13 changes: 13 additions & 0 deletions src/Router/Core.php
Expand Up @@ -171,6 +171,19 @@ 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;
}
Expand Down

0 comments on commit 0a14f6b

Please sign in to comment.