Пример #1
0
 /**
  * Set the theme based on:
  *  1) manual setting
  *  2) the request params (e.g. `?theme=MySpecialTheme`)
  *  3) the request attributes (e.g. `_theme`)
  *  4) the default system theme
  * @param string|null $newThemeName
  * @param Request|null $request
  * @return mixed
  * kernel::getTheme() @throws \InvalidArgumentException if theme is invalid.
  */
 private function setActiveTheme($newThemeName = null, Request $request = null)
 {
     $activeTheme = !empty($newThemeName) ? $newThemeName : \System::getVar('Default_Theme');
     if (isset($request)) {
         // @todo do we want to allow changing the theme by the request?
         $themeByRequest = $request->get('theme', null);
         if (!empty($themeByRequest)) {
             $activeTheme = $themeByRequest;
         }
         $themeByRequest = $request->attributes->get('_theme');
         if (!empty($themeByRequest)) {
             $activeTheme = $themeByRequest;
         }
     }
     try {
         $this->activeThemeBundle = $this->kernel->getTheme($activeTheme);
         $this->activeThemeBundle->loadThemeVars();
     } catch (\Exception $e) {
         // fail silently, this is a Core < 1.4 theme.
     }
 }
Пример #2
0
 /**
  * Add autoloaders to kernel or include files from json
  *
  * @param ZikulaKernel $kernel
  * @param array        $autoload
  */
 public function addAutoloaders(ZikulaKernel $kernel, array $autoload)
 {
     if (isset($autoload['psr-0'])) {
         foreach ($autoload['psr-0'] as $prefix => $path) {
             $kernel->getAutoloader()->add($prefix, $path);
         }
     }
     if (isset($autoload['psr-4'])) {
         foreach ($autoload['psr-4'] as $prefix => $path) {
             $kernel->getAutoloader()->addPsr4($prefix, $path);
         }
     }
     if (isset($autoload['classmap'])) {
         $kernel->getAutoloader()->addClassMap($autoload['classmaps']);
     }
     if (isset($autoload['files'])) {
         foreach ($autoload['files'] as $path) {
             include $path;
         }
     }
 }