public function init() { /* * Basically, what we want to to is load app's route config * */ $path = path('apps') . $this->app . path('ds') . 'Config' . path('ds') . 'router.php'; //startMeasure('App RouterProvider: ' . $path); $phpProvider = new Php(['file' => $path, 'prefix' => isset($this->config['prefix']) ? $this->config['prefix'] : null]); $phpProvider->init(); $this->router->addCachedInit(['autoloader' => [path('apps') . $this->app . path('ds') . 'src'], 'view' => [path('apps') . $this->app . path('ds') . 'src' . path('ds')]])->writeCache(); /* * And autoloader * */ // @T00D00 - this needs to be called on initialization ... $path = path('apps') . $this->app . path('ds') . 'src'; message('Registering autoloader (App route provider) ' . $path); autoloader()->add('', $path); /* * And add to twig? * */ Twig::addDir($path . path('ds'), Twig::PRIORITY_APP); /* * And then you finally realize this should be refactored to some kind of Command or AppInitializator * */ //stopMeasure('App RouterProvider: ' . $path); }
public function registerAutoloaders($autoloaders, $object = null) { if (!is_array($autoloaders)) { $autoloaders = [$autoloaders]; } foreach ($autoloaders as $autoloader) { if (!is_array($autoloader)) { $autoloader = [$autoloader]; } foreach ($autoloader as $a) { message('Registering autoloader (Registrator) ' . $a); autoloader()->add('', $a, $a == path('app_src')); Twig::addDir($a); } } }
protected function initDev() { $cache = $this->getCache(); $data = $cache->get(); $this->routes = $data['routes']; $this->cachedInit = $data['cachedInit']; if (isset($this->cachedInit['autoloader'])) { foreach ($this->cachedInit['autoloader'] as $dir) { message('Register autoloader (Dev Router) ' . $dir); autoloader()->add('', $dir); } } if (isset($this->cachedInit['view'])) { foreach ($this->cachedInit['view'] as $dir) { Twig::addDir($dir); } } }
<?php require_once __DIR__ . "/../config/config.php"; require_once __DIR__ . "/../lib/util.functions.php"; autoloader(__DIR__ . "/../lib/"); autoloader(__DIR__ . "/../lib/dao/"); $session = Session::start(); $session->clear('user'); // clear auth cookies if they're present clearTokenCookie(); header("Location: login.php");