コード例 #1
0
 /**
  * SEtting the value for the system settings
  *
  * @param string $key
  * @param string $value
  * @param string $preFix
  * @param bool   $debug
  */
 private static function _setSettings($key, $value, $preFix = '', $debug = false)
 {
     $paramName = SystemSettings::TYPE_MAGENTO_SYNC;
     self::_log('-- Trying to set SystemSettings for: "' . $paramName . '" with new value: ' . $value, __CLASS__ . '::' . __FUNCTION__, $preFix);
     $settings = self::_getSettings($preFix . self::TAB, $debug);
     if (!is_array($settings)) {
         $settings = array();
     }
     self::_log('Before setting: ' . preg_replace('/\\s+/', ' ', print_r($settings, true)), '', $preFix . self::TAB);
     $settings[$key] = $value;
     self::_log('After setting: ' . preg_replace('/\\s+/', ' ', print_r($settings, true)), '', $preFix . self::TAB);
     if (!($settingObj = SystemSettings::getByType($paramName)) instanceof SystemSettings) {
         $settingObj = new SystemSettings();
         $settingObj->setType($paramName)->setDescription($paramName);
     }
     $jsonString = json_encode($settings);
     self::_log('Saving new Settings: ' . $jsonString, '', $preFix . self::TAB);
     $settingObj->setValue($jsonString)->save();
     self::_log('DONE', '', $preFix . self::TAB);
     self::_log('');
     self::$_cache[__CLASS__ . ':settings:' . $paramName] = $settings;
 }