/** * Apply a preset * * @param Preset $preset */ public function applyPreset(Preset $preset) { $this->appliedPreset = $preset; /* Saving data so later on we can reuse it without worrying about older applied presets */ $data = $this->data; foreach ($data['options'] as &$emptyOption) { if ($presetOption = $preset->getOption($emptyOption['name'])) { if (!is_array($emptyOption['specific'])) { $emptyOption['specific'] = array(); } $emptyOption['specific'] = array_merge($emptyOption['specific'], $presetOption->getValue()); } } // $this->options = array(); foreach ($data['options'] as $option) { $optionReflection = new \ReflectionClass($option['type']); if ($optionReflection->isSubclassOf('Cx\\Core_Modules\\TemplateEditor\\Model\\Entity\\Option')) { if ($this->cx->getMode() == Cx::MODE_BACKEND || $this->cx->getUser()->getFWUserObject()->objUser->login() && isset($_GET['templateEditor'])) { if (isset($_SESSION['TemplateEditor'][$this->theme->getId()][$option['name']])) { $option['specific'] = array_merge($option['specific'], $_SESSION['TemplateEditor'][$this->theme->getId()][$option['name']]->toArray()); } } $this->options[$option['name']] = $optionReflection->newInstance($option['name'], $option['translation'], $option['specific']); } } }