Ejemplo n.º 1
0
 /**
  * Checks each route against the request and on match 
  */
 public static function proccess(Request $request = null)
 {
     static::init();
     if (is_null($request)) {
         $request = Request::real();
     }
     foreach (static::$routes as $name => $route) {
         if ($route["route"]->match($request)) {
             if ($route["closure"]) {
                 call_user_func_array($route["closure"], array($route));
             } elseif (Event::hasListeners("sugi.route")) {
                 Event::fire("sugi.route", $route);
             } else {
                 $r = $route["route"];
                 App::execute("Controller_{$r->get('controller')}", "action_{$r->get('action')}", array($r->get('param'))) and exit;
             }
         }
     }
 }
Ejemplo n.º 2
0
Archivo: Route.php Proyecto: rezon/sugi
 /**
  * Match defined route rules against the request
  * @param Sugi\HTTP\Request $request
  * @return boolean - true if the request match defined route
  */
 public function match(Request $request = null)
 {
     // setting default values as a variables
     $this->variables = $this->defaults;
     if (is_null($request)) {
         $request = Request::real();
     }
     if ($this->matchScheme($request->scheme()) === false) {
         return false;
     }
     if ($this->matchMethod($request->method()) === false) {
         return false;
     }
     if ($this->matchHost($request->host()) === false) {
         return false;
     }
     if ($this->matchPath($request->path()) === false) {
         return false;
     }
     return true;
 }