getOption(static::OPTION_CURRENT); } /** * @inheritdoc */ public function addTheme(Theme $theme, $protectAlreadyExistingThemes = true) { $themes = $this->getAllThemes(); $themeId = $theme->getId(); if ($protectAlreadyExistingThemes) { $themeId = $this->getUniqueId($theme); } $themes[$themeId] = [ static::THEME_CLASS_OFFSET => get_class($theme), static::THEME_OPTIONS_OFFSET => ($theme instanceof Configurable) ? $theme->getOptions() : [] ]; $this->setOption(static::OPTION_AVAILABLE, $themes); return $themeId; } /** * @inheritdoc */ public function setCurrentTheme($themeId) { if (!$this->hasTheme($themeId)) { throw new \common_exception_Error('Theme ' . $themeId . ' not found'); } $this->setOption(static::OPTION_CURRENT, $themeId); } /** * @inheritdoc */ public function getAllThemes() { $themes = (array)$this->getOption(static::OPTION_AVAILABLE); foreach ($themes as $key => $theme) { if (is_array($theme) && isset($theme[static::THEME_CLASS_OFFSET])) { $options = isset($theme[static::THEME_OPTIONS_OFFSET]) ? $theme[static::THEME_OPTIONS_OFFSET] : [] ; $theme = $this->getServiceManager()->build($theme[static::THEME_CLASS_OFFSET], $options); } $themes[$key] = $theme; } return $themes; } /** * @inheritdoc */ public function removeThemeById($themeId) { if (!$this->hasTheme($themeId)) { return false; } $themes = $this->getOption(static::OPTION_AVAILABLE); unset($themes[$themeId]); $this->setOption(static::OPTION_AVAILABLE, $themes); return true; } }