Skip to content

Commit b21a18d

Browse files
committed
feat: add resetRoutes flag to search filters only for Auto Routes
1 parent 5340ec6 commit b21a18d

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

system/Commands/Utilities/Routes/FilterCollector.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@
2121
*/
2222
final class FilterCollector
2323
{
24+
/**
25+
* Whether to reset Defined Routes.
26+
*
27+
* If set to true, route filters are not found.
28+
*/
29+
private bool $resetRoutes;
30+
31+
public function __construct(bool $resetRoutes = false)
32+
{
33+
$this->resetRoutes = $resetRoutes;
34+
}
35+
2436
/**
2537
* @param string $method HTTP method
2638
* @param string $uri URI path to find filters for
@@ -49,7 +61,13 @@ public function get(string $method, string $uri): array
4961

5062
private function createRouter(Request $request): Router
5163
{
52-
return new Router(Services::routes(), $request);
64+
$routes = Services::routes();
65+
66+
if ($this->resetRoutes) {
67+
$routes->resetRoutes();
68+
}
69+
70+
return new Router($routes, $request);
5371
}
5472

5573
private function createFilters(Request $request): Filters

0 commit comments

Comments
 (0)