Example #1
0
 /**
  * Starts the route manager
  * @throws \Pvik\Web\NoRouteFoundException
  */
 public function start()
 {
     if (Config::$config['UnderConstruction']['Enabled'] == true) {
         $this->executeUnderConstruction(Path::realPath(Config::$config['UnderConstruction']['Path']));
     } else {
         //Request::getInstance()->fetchUrl();
         $request = $this->findRoute();
         if ($request != null) {
             // start output buffering
             ob_start();
             $route = $request->getRoute();
             // execute controller
             ControllerManager::executeController($route['Controller'], $route['Action'], $request);
             // end output buffering and output the buffer
             echo ob_get_clean();
         } else {
             throw new \Pvik\Web\NoRouteFoundException('No route found for ' . $this->url);
         }
     }
 }
Example #2
0
 /**
  * Redirects to another controllers action with passing the original parameters.
  * @param string $controllerName
  * @param string $actionName 
  */
 protected function redirectToController($controllerName, $actionName, Request $request = null)
 {
     if ($request == null) {
         $request = $this->request;
     }
     Log::writeLine('Redirecting to controller: ' . $controllerName);
     Log::writeLine('Redirecting to action: ' . $actionName);
     ControllerManager::executeController($controllerName, $actionName, $request);
 }