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 init() { //startMeasure('Src RouterProvider: ' . $this->config['src']); foreach ([path('app_src') . $this->config['src'] . path('ds'), path('root') . $this->config['src'] . path('ds')] as $dir) { if (is_dir($dir)) { context()->get(Config::class)->parseDir($dir); } } foreach ([path('app_src') . $this->config['src'] . path('ds') . 'Config/router.php', path('root') . $this->config['src'] . path('ds') . 'Config/router.php'] as $file) { if (!is_file($file)) { continue; } $phpProvider = new Php(['file' => $file, 'prefix' => isset($this->config['prefix']) ? $this->config['prefix'] : null]); $phpProvider->init(); // then we have to find provider $class = $this->src . '\\Provider\\Config'; if (class_exists($class)) { $provider = Reflect::create($class); $provider->register(); } } //stopMeasure('Src RouterProvider: ' . $this->config['src']); }