public function testSaveOption() { $themeOption = $this->themeOptionRepository->get(new Theme(null, null, 'standard_3_0')); $newColor = 'dddddd'; $this->assertTrue($themeOption instanceof OptionSet); if ($themeOption instanceof OptionSet) { /** * @var $color ColorOption */ $color = $themeOption->getOption('main_color'); $color->handleChange($newColor); $this->assertTrue($color->getColor() == $newColor); } $this->assertTrue($this->themeOptionRepository->save($themeOption)); }
/** * Remove a preset * * @param array $params List of get and post parameters which were sent to * the json adapter. */ public function removePreset($params) { global $_ARRAYLANG; \Env::get('init')->loadLanguageData('TemplateEditor'); if (!Preset::isValidPresetName($params['post']['preset'])) { return; } $presetName = $params['post']['preset']; /** * Default shouldn't be deletable */ if ($presetName == 'Default') { throw new \LogicException($_ARRAYLANG['TXT_CORE_MODULE_TEMPLATEEDITOR_REMOVE_PRESET_DEFAULT_WARNING']); } $themeID = isset($params['post']['tid']) ? intval($params['post']['tid']) : 1; $themeRepository = new ThemeRepository(); $theme = $themeRepository->findById($themeID); $fileStorage = new OptionSetFileStorage($this->cx->getWebsiteThemesPath()); $themeOptionRepository = new OptionSetRepository($fileStorage); $themeOptions = $themeOptionRepository->get($theme); $preset = $themeOptions->getPresetRepository()->getByName($presetName); if ($themeOptions->getActivePreset()->getName() == $preset->getName()) { $themeOptions->setActivePreset($themeOptions->getPresetRepository()->getByName('Default')); $themeOptionRepository->save($themeOptions); } $themeOptions->getPresetRepository()->remove($preset); }