/** * Returns the event dispatcher. * * @return Symfony\Component\EventDispatcher\EventDispatcher */ public function getEventDispatcher() { if (is_null($this->eventDispatcher)) { $this->eventDispatcher = $this->kernel->getEventDispatcher(); } return $this->eventDispatcher; }
/** * Returns the paths to this theme. * * @return string[] */ public function getPaths() { $paths = array(); $baseDir = $this->kernel->getThemeDir(); $themes = $this->getThemeHierachy(); foreach ($themes as $theme) { $paths[] = $baseDir . $theme . "/"; } return $paths; }
/** * 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; }