findRouteFor() public method

Traverses children recursively to find a matching route. First looks to see if a static (non-parametric, i.e. /this_is_static/ vs. /$this_is_dynamic/) match exists. If not, we match against dynamic children. We reverse and step backwards through the array because $index > 0 is less costly than $index < count($parts) in PHP.
public findRouteFor ( Request $request ) : RoutingResult
$request Request
return RoutingResult
Example #1
0
 public function getControllerFor(Request $request, RtNode $routes)
 {
     $routeResult = $routes->findRouteFor($request);
     if ($routeResult->routeExists) {
         if ($routeResult->methodIsSupported) {
             $controller = $this->getControllerFromRouteResult($request, $routeResult);
         } else {
             throw new RecessResponseException('METHOD not supported, supported METHODs are: ' . implode(',', $routeResult->acceptableMethods), ResponseCodes::HTTP_METHOD_NOT_ALLOWED, get_defined_vars());
         }
     } else {
         throw new RecessResponseException('Resource does not exist.', ResponseCodes::HTTP_NOT_FOUND, get_defined_vars());
     }
     Application::activate($request->meta->app);
     $this->controller = $controller;
     return $controller;
 }