Example #1
0
 /**
  * Determines controller and action 
  */
 public function run()
 {
     $uri = $this->getCurrentURI();
     $route = NULL;
     $params = array();
     // Try to match a pattern
     foreach ($this->routes as $r) {
         // Case 1: no params => pattern == uri
         if ($r->getPattern() == $uri) {
             $route = $r;
             break;
         }
         // Case 2: params - let's go
         $result = Router::matchRoute($r, $uri);
         if ($result !== false && is_array($result)) {
             $params = $result;
             $route = $r;
             // Don't break here: maybe there is a
             // route that matches better :D
         }
     }
     if ($route != NULL) {
         $this->runController($route, $params);
     } else {
         System::displayError(System::getLanguage()->_('ErrorRouteNotFound'), '404 Not Found');
     }
 }