Exemplo n.º 1
0
 public static function render($path, array $args = array())
 {
     if (self::$_instance === NULL) {
         self::init();
     }
     $args['request'] = Request::getInstance();
     $args['static_url'] = Rivet::getInstance()->config['static_url'];
     $template = self::$_instance->twig->loadTemplate($path);
     $template->routes = Routes::getInstance();
     self::$_instance->body = $template->render($args);
     return self::$_instance->body;
 }
Exemplo n.º 2
0
 public function dispatch()
 {
     if (self::$_instance === NULL) {
         self::getInstance();
     }
     $routes = Routes::getInstance();
     $route = $routes->match();
     if ($route) {
         $view = $route->run();
         if ($view instanceof Response) {
             self::$_instance->response = $view;
         }
         // allow returning a response straight from the view
         self::$_instance->response = new Response($view);
         return self::$_instance->response;
     }
     return notfound();
 }
Exemplo n.º 3
0
function reverse()
{
    $routes = Routes::getInstance();
    return $routes->reverse(func_get_args());
}
Exemplo n.º 4
0
 public function __construct($route_name, $params, $lineno)
 {
     parent::__construct($lineno);
     $routes = Routes::getInstance();
     $this->url = $routes->reverse(array($route_name, $params));
 }
Exemplo n.º 5
0
 public static function doRoute()
 {
     $routesInstance = Routes::getInstance();
     $routeAction = $routesInstance->getAction();
     // make sure we dont show a 404
     global $wp_query;
     if ($wp_query->is_404) {
         $wp_query->is_404 = false;
         $wp_query->is_archive = true;
     }
     header("HTTP/1.0 200 OK");
     //header("Content-Type: text/html; charset=UTF-8");
     //var_dump($routeAction->action);
     //var_dump($routeAction);
     if ($routeAction->action['type'] == 'pagename') {
         query_posts(array('pagename' => $routeAction->action['name']));
     } else {
         if ($routeAction->action['type'] == 'filename') {
             include TEMPLATEPATH . '/' . $routeAction->action['name'];
             exit;
         }
     }
 }
Exemplo n.º 6
0
 /**
  * Evaluate route by given URL
  */
 private function evaluateRoute()
 {
     Routes::getInstance()->loadRoutes()->evaluateURL();
 }