Skip to content

Commit 5b34927

Browse files
committed
feat: add support for lingo + context on hooks
1 parent 86278b9 commit 5b34927

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Router.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ public static function match(string $allowedMethods, string $pattern, $handler)
183183
'pattern' => $pattern,
184184
'handler' => $handler,
185185
'name' => $routeOptions['name'] ?? '',
186+
'lingo.no_locale_prefix' => $routeOptions['lingo.no_locale_prefix'] ?? false,
186187
];
187188

188189
if ($routeOptions['middleware'] || !empty(static::$routeGroupMiddleware)) {
@@ -625,7 +626,12 @@ public static function hook(string $name, callable $handler)
625626
*/
626627
private static function callHook(string $name)
627628
{
628-
return is_callable(static::$hooks[$name]) ? static::$hooks[$name]() : null;
629+
if (is_callable(static::$hooks[$name])) {
630+
$context = static::$hooks[$name](['routes' => static::$routes]);
631+
static::$routes = $context['routes'] ?? static::$routes;
632+
}
633+
634+
return $context ?? null;
629635
}
630636

631637
/**

0 commit comments

Comments
 (0)