* @copyright 2021 DIGITAL RETAIL TECHNOLOGIES SL * @license https://opensource.org/licenses/MIT The MIT License * * Don't forget to prefix your containers with your own identifier * to avoid any conflicts with others containers. */ class RetailcrmSettingsItem { private $paramKey; protected $configKey; private $default; public function __construct($paramKey, $configKey, $default = '') { $this->paramKey = $paramKey; $this->configKey = $configKey; $this->default = $default; } public function updateValue() { if (!$this->issetValue()) { return; } $value = $this->getValueForUpdate(); Configuration::updateValue($this->configKey, $value); } public function issetValue() { return Tools::getIsset($this->paramKey); } public function deleteValue() { return Configuration::deleteByName($this->configKey); } public function getValue() { return Tools::getValue($this->paramKey); } public function getValueForUpdate() // todo make protected { return $this->getValue(); } public function getValueStored() { return Configuration::get($this->configKey, null, null, null, $this->default); } public function getValueWithStored() { if ($this->issetValue()) { return $this->getValue(); } return $this->getValueStored(); } }