/** * Executes the system routing * @throws Exception */ public function execute($routes) { // tries to find the route and run the given action on the controller try { // the controller and action to execute $controller = null; $action = null; // tries to find a simple route $routeFound = $this->_getSimpleRoute($routes, $controller, $action); if (!$routeFound) { // tries to find the a matching "parameter route" $routeFound = $this->_getParameterRoute($routes, $controller, $action); } // no route found, throw an exception to run the error controller if (!$routeFound || $controller == null || $action == null) { throw new Exception('no route added for ' . $_SERVER['REQUEST_URI']); } else { // executes the action on the controller $controller->execute($action); } } catch (Exception $exception) { // runs the error controller $controller = new ErrorController(); $controller->setException($exception); $controller->execute('error'); } }