/** * Gets the default theme. * @return Theme */ public function getDefaultTheme() { // TODO: Default theme should come from config $theme = new Theme(); $theme->populate(array('name' => 'default', 'description' => 'Default theme')); return $theme; }
/** * Gets the active theme. * * @return ThemeInterface */ public function getActive() { $moduleManager = $this->serviceManager->get('ModuleManager'); $themeManager = $this->serviceManager->get('ThemeManager'); $module_names = $moduleManager->getModules(); foreach ($module_names as $module_name) { $module = $moduleManager->getModule($module_name); if ($module instanceof ThemeProviderInterface) { // Get the themes $themes_path = $module->getDir() . DIRECTORY_SEPARATOR . $themeManager->getThemeFolder(); if (is_dir($themes_path)) { $dir = new DirectoryIterator($themes_path); foreach ($dir as $fileinfo) { if ($fileinfo->isDir() && !$fileinfo->isDot()) { // Probably got a theme // Check the info file $info_file = $themes_path . DIRECTORY_SEPARATOR . $fileinfo->getFilename() . DIRECTORY_SEPARATOR . 'info.json'; if (is_readable($info_file)) { $theme_info = file_get_contents($info_file); $theme_info = Json::decode($theme_info, Json::TYPE_ARRAY); $theme_info = array_change_key_case($theme_info, CASE_LOWER); $theme = new Theme(); $theme->populate($theme_info); if ($theme->isActive()) { return $theme; } } } } } } } // No active theme, return default! return $themeManager->getDefaultTheme(); }