Example #1
0
 public function dispatch(Request $request, InjectionContainer $injections)
 {
     $guard = $this->loadGuard($request->getUser());
     $route = new Route($request->getMethod(), $request->getUri(), $guard, $injections);
     if (!$route->hasAccess()) {
         $redirect = $guard->getHttpRedirect($route->getFolders());
         if (!empty($redirect)) {
             redirect($redirect);
         }
         showError(403);
     }
     //Load the page
     if ($route->getMethod() !== "GET" && $this->isCsrfViolation($guard, $route->getFolders())) {
         redirect($_SERVER['HTTP_REFERER']);
     } elseif ($route->isValidRoute()) {
         $class = $route->getController();
         $function = $route->getFunction();
         $controller = new $class();
         call_user_func_array(array(&$controller, $function), $route->getInjections());
     } else {
         showError(404);
     }
 }