Ejemplo n.º 1
0
 /**
  * The resolve function gets the current route object, it initializes the Input capture
  * and triggers the required controller based on the route config file.
  *
  * @return void
  * @author Dan Cox
  */
 public static function resolve()
 {
     $route = static::$router->match(static::$request->getPathInfo(), $_SERVER);
     Input::init(static::$request->request);
     // Load the old input if there
     Input::loadOld();
     if ($route) {
         $params = $route->params;
         // Set as the current route;
         static::$current = $route;
         $action = $params['action'];
         unset($params['action']);
         $controller = explode('@', $action);
         // Load the controller
         require_once dirname(__DIR__) . '/controllers/' . $controller[0] . '.php';
         $class = new $controller[0]();
         call_user_func_array(array($class, $controller[1]), $params);
     } else {
         // No matching route
         throw new \Exception('No matching routes found');
     }
 }
Ejemplo n.º 2
0
 /**
  * Gets the old input that can be used in the twig templating language
  *
  * @return void
  * @author Dan Cox
  */
 private function _function_Input()
 {
     return new \Twig_SimpleFunction('Input', function ($key) {
         return Input::old($key);
     });
 }
Ejemplo n.º 3
0
 /**
  * With Input - Saves old input to the session.
  *
  * @return object
  * @author Dan Cox
  */
 public function withInput()
 {
     Input::save();
     return $this;
 }