Exemple #1
0
 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);
 }
Exemple #2
0
 public function init()
 {
     //startMeasure('Namespace RouterProvider: ' . $this->namespace);
     $explNamespace = explode('\\', $this->namespace);
     $arrMethods = get_class_methods($this->namespace . '\\Controller\\' . end($explNamespace));
     foreach ($arrMethods as $method) {
         if (substr($method, -6) == 'Action') {
             $action = substr($method, 0, -6);
             $urlProvider = new Url((isset($this->config['prefix']) ? $this->config['prefix'] : null) . '/' . $action, ['controller' => $this->namespace, 'view' => $action]);
             $urlProvider->load();
         }
     }
     $configPath = $this->config['src'] . str_replace('\\', '/', $this->namespace);
     $phpProvider = new Php(['src' => $configPath, 'prefix' => isset($this->config['prefix']) ? $this->config['prefix'] : null]);
     $phpProvider->load();
     //stopMeasure('Namespace RouterProvider: ' . $this->namespace);
 }
Exemple #3
0
 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']);
 }