Skip to content

Commit ec326ad

Browse files
committed
Fixing tests after routing options PR was merged
1 parent 01a45be commit ec326ad

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

system/Router/Router.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,44 @@ public function handle(?string $uri = null)
221221
// Restart filterInfo
222222
$this->filtersInfo = [];
223223

224+
<<<<<<< HEAD
225+
=======
226+
$useDefinedRoutes = $this->collection->shouldUseDefinedRoutes();
227+
$useAutoRoute = $this->collection->shouldAutoRoute();
228+
229+
// Let devs know if both are disabled
230+
if (! $useDefinedRoutes && ! $useAutoRoute) {
231+
throw RouterException::forNoRoutingAvailable();
232+
}
233+
234+
// Fast path 1: Auto-routing ONLY (no defined routes to check)
235+
if ($useAutoRoute && ! $useDefinedRoutes) {
236+
$this->autoRoute($uri);
237+
238+
$this->processRouteAttributes();
239+
240+
return $this->controllerName();
241+
}
242+
243+
// Fast path 2: Defined routes ONLY (no auto-routing fallback)
244+
if ($useDefinedRoutes && ! $useAutoRoute) {
245+
if ($this->checkRoutes($uri)) {
246+
if ($this->collection->isFiltered($this->matchedRoute[0])) {
247+
$this->filtersInfo = $this->collection->getFiltersForRoute($this->matchedRoute[0]);
248+
}
249+
250+
$this->processRouteAttributes();
251+
252+
return $this->controller;
253+
}
254+
255+
throw new PageNotFoundException(
256+
"Can't find a route for '{$this->collection->getHTTPVerb()}: {$uri}'.",
257+
);
258+
}
259+
260+
// Original path: BOTH enabled (check defined routes first, then auto-route)
261+
>>>>>>> 8f675dc60a (Fixing tests after routing options PR was merged)
224262
// Checks defined routes
225263
if ($this->checkRoutes($uri)) {
226264
if ($this->collection->isFiltered($this->matchedRoute[0])) {

0 commit comments

Comments
 (0)