/** * {@inheritDoc} */ public function saveParameter($namespace, $name, $value) { $eventParams = ['namespace' => $namespace, 'name' => $name, 'value' => $value]; $this->getEventManager()->trigger(__FUNCTION__, $this, $eventParams); if ($this->options->getCacheOptions()->isEnabled()) { $this->getCacheManager()->delete($namespace); } $parameter = $this->settingsMapper->findParameter($namespace, $name); if ($parameter) { if ($parameter->getValue() != $value) { $parameter->setValue($value); $this->getEventManager()->trigger('updateParameter', $this, ['parameter' => $parameter]); $this->settingsMapper->updateParameter($parameter); } } else { $parameterEntityClass = $this->options->getParameterEntityClass(); $parameter = new $parameterEntityClass(); $parameter->setNamespace($namespace); $parameter->setName($name); $parameter->setValue($value); $this->getEventManager()->trigger('insertParameter', $this, ['parameter' => $parameter]); $this->settingsMapper->insertParameter($parameter); } $this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, $eventParams); }
/** * {@inheritDoc} */ public function getSettingsArray($namespace) { $resultSet = $this->settingsMapper->findByNamespace($namespace); $arraySettings = []; foreach ($resultSet as $parameter) { $arraySettings[$parameter->getName()] = $parameter->getValue(); } return $arraySettings; }