예제 #1
0
파일: Loader.php 프로젝트: skelpo/framework
 /**
  * Build the routes for all controllers.
  *
  * @param Symfony\Component\Routing\Route[] $routes The routes that are already established.
  * @return The routes as a RouteCollection.
  */
 private function buildRoutes($routes, $routesWithParameters)
 {
     $rootPath = $this->kernel->getRootDir();
     $modules = $this->kernel->getModules();
     // build all the routes
     $controllerDirs = array();
     foreach ($modules as $module) {
         $controllerDirs[] = "App/Controllers/" . $module->getName() . "/";
     }
     $pluginDir = $this->kernel->getFramework()->getPluginDir();
     $file = $this->kernel->getCache("plugins");
     $plugins = $file->getContent();
     if ($plugins == "") {
         $plugins = array();
     }
     foreach ($plugins as $p) {
         $pf = $pluginDir . $p['name'] . "/";
         if (is_dir($pf)) {
             foreach ($modules as $module) {
                 if (is_dir($pf . "Controllers/" . $module->getName() . "/")) {
                     $controllerDirs[] = "App/Plugins/" . $p['name'] . "/Controllers/" . $module->getName() . "/";
                 }
             }
         }
     }
     $lookFor = "Controller.php";
     foreach ($controllerDirs as $dir) {
         $path = $rootPath . $dir;
         if (!is_dir($path)) {
             continue;
         }
         $module = substr($path, strpos($path, "Controllers/") + 12);
         $module = strtolower(substr($module, 0, -1));
         $files = scandir($path);
         foreach ($files as $file) {
             $l = strlen($file);
             if ($l > 14) {
                 if (substr($file, $l - 14) == $lookFor) {
                     $this->buildRoutesForClass($path, $file, $module, $routes, $routesWithParameters);
                 }
             }
         }
     }
     return $routes;
 }
예제 #2
0
 /**
  * Returns the root dir of the application.
  *
  * @return string
  */
 public function getRootDir()
 {
     return $this->kernel->getRootDir();
 }