示例#1
0
 /**
  * Initializes application with the provided themes.
  *
  * @param ThemeInterface|null $theme
  */
 protected function initializeTheme(ThemeInterface $theme = null)
 {
     if (null === $theme) {
         return;
     }
     $layoutDir = $theme->getLayoutDir();
     if (false != $layoutDir && is_dir($layoutDir)) {
         $this->app->getRenderer()->addLayoutDir($layoutDir);
     }
     $viewDir = $theme->getViewDir();
     if (false != $viewDir && is_dir($viewDir)) {
         $this->app->getRenderer()->addScriptDir($viewDir);
     }
     $helperDir = $theme->getHelperDir();
     if (false != $helperDir && is_dir($helperDir)) {
         $this->app->getRenderer()->addHelperDir($helperDir);
     }
     $routing = $this->app->getRouting();
     if ($routing instanceof RouteCollection) {
         $staticDir = $this->app->getContainer()->getParameter('theme.static.dir');
         $staticDir = realpath($staticDir . DIRECTORY_SEPARATOR . $theme->getName());
         if (false !== $staticDir) {
             $routing->setStaticDir($staticDir);
         }
     }
 }
示例#2
0
 /**
  * Adds bundle's helpers directory into application's renderer.
  *
  * @param Config        $config
  * @param callable|null $recipe
  */
 private function addHelpersDir(Config $config, callable $recipe = null)
 {
     if (false === $this->runRecipe($config, $recipe)) {
         $directory = realpath(dirname($config->getBaseDir()) . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'helpers');
         if (false !== $directory) {
             $this->application->getRenderer()->addHelperDir($directory);
         }
     }
 }