Пример #1
0
 public function run($url)
 {
     // Init
     $this->init();
     // Route
     $this->pluginLoader->call('route');
     // Routing
     $this->url = $url;
     $this->callHook('router_beforeroute');
     $this->router->run();
     $this->callHook('router_afterroute');
     $this->callHook('app_endlife');
     return true;
 }
Пример #2
0
 public function initRouter()
 {
     $options = App::conf('app', 'router', array());
     $router = Router::factory($options);
     $router->setConfig(App::conf('route'));
     return $router;
 }
Пример #3
0
 /**
  * Adds an javascript objectto the content.
  *
  * @param Javascript $script
  *
  * @return JavascriptObject
  */
 public function &add(JavascriptObject $js)
 {
     if ($this->router->isAjax()) {
         /* @var $ajax \Core\Ajax\Ajax */
         $ajax = $this->di->get('core.ajax');
         switch ($js->getType()) {
             case 'file':
                 $cmd = $ajax->createActCommand();
                 $cmd->getScript($js->getScript());
                 break;
         }
         $return = null;
         return $return;
     }
     $area = $js->getDefer() ? 'below' : 'top';
     if ($this->mode == 'core') {
         $this->core_js[$area][] = $js;
     } else {
         $this->app_js[$area][] = $js;
     }
     return $js;
 }
Пример #4
0
 /**
  * @TODO Bad code. :/
  *
  * @param string $stage
  */
 private function send404($stage = 'not set')
 {
     $msg = $stage . ' - Page not found';
     if ($this->router->isAjax()) {
         $cmd = new \Core\Ajax\Commands\Dom\HtmlCommand('#content', $msg);
         $ajax = $this->di->get('core.ajax');
         $ajax->addCommand($cmd);
         $result = $ajax->process();
         return $result;
     }
     $this->http->header->sendHttpError(404);
     return $msg;
 }
Пример #5
0
 /**
  * Launches the prerequisites to using the application
  */
 public function run()
 {
     require_once ROOT . '/core/autoloader/Autoloader.php';
     $paths = (require_once ROOT . '/app/config/paths.php');
     $autoloader = new Autoloader($paths);
     $autoloader->start();
     $config = (require ROOT . '/app/config/app.php');
     define('DEBUG', Config::get()->read('debug'));
     if (!DEBUG) {
         error_reporting(0);
     } else {
         ini_set('display_errors', 'on');
         error_reporting(E_ALL);
     }
     session_cache_expire(Config::get()->read('session'));
     session_start();
     require_once ROOT . '/core/helpers.php';
     $router = new Router(isset($_GET['url']) ? $_GET['url'] : null);
     require_once ROOT . '/app/routes.php';
     $this->router = $router;
     $middleware = new Middleware();
     $middleware->load();
     $router->run();
 }
Пример #6
0
 public function testNormalize()
 {
     $router = \Core\Router\Router::factory(array('type' => 'rewrite'));
     $this->assertTrue($router->normalizeRoute('One/Two/ThreeFour') == 'one/two/three-four');
 }
Пример #7
0
 public function initRouter()
 {
     $options = array('type' => 'Console', 'default_route' => 'help/index');
     $router = Router::factory($options);
     return $router;
 }