Esempio n. 1
0
 /**
  * Create a Request-object with the data from the http-request and the session
  * @return Request
  */
 public function build()
 {
     $request = new Request();
     $uri = $this->cleanUri($_SERVER['REQUEST_URI']);
     $request->setMethod($this->deriveRequestMethod());
     $filteredUriLang = $this->findLanguageInUri($uri);
     $request->setUri($filteredUriLang->uri);
     $request->setLanguage($filteredUriLang->language);
     $request->setUser(SessionManager::loadUser());
     $request->setFlash(SessionManager::cleanFlash());
     $request->setParams($_POST);
     return $request;
 }
Esempio n. 2
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);
     }
 }