/** * Recognize a Route Based on the Request. * * @param Request request the Request * @return ActionController * @throws RoutingEception */ public static function recognize(Request $request) { $r = new ActionControllerRouting($request); try { $route = $r->findRoute($request); return $route->createControllerInstance($request); } catch (RoutingException $rEx) { // exception thrown by findRoute if we dont match any of the registered route. // load 404 route, if fails too try the default route, this are named routes. // echo $rEx; try { return Map::getInstance()->getRouteByName(Route::NOTFOUND)->createControllerInstance($request); } catch (RoutingException $rEx2) { return Map::getInstance()->getRouteByName(Route::WELCOME)->createControllerInstance($request); } } }
<?php // $Id$ $map = Map::getInstance(); $map->add(new Route(':controller/:action/:id'));