/**
  * setting method
  *
  * Query the application setting model, if there is no result query Configure::read - and cache
  * the result
  *
  * @param string $cacheKey ''
  * @param mixed $dummy null
  * @return void
  * @access public
  */
 public static function setting($id = '', $aroId = null)
 {
     if (MiCache::$setting === null) {
         MiCache::config();
     }
     if (MiCache::$settings[MiCache::$setting]['batchLoadSettings']) {
         if (strpos($id, '.')) {
             $keys = explode('.', $id);
             $mainId = array_shift($keys);
             if (!array_key_exists($aroId . '_' . $mainId, MiCache::$_appSettingCache)) {
                 MiCache::$_appSettingCache[$aroId . '_' . $mainId] = MiCache::setting($mainId, $aroId);
             }
             $array = MiCache::$_appSettingCache[$aroId . '_' . $mainId];
             $j = count($keys);
             $return = null;
             if (is_array($array)) {
                 foreach ($keys as $i => $key) {
                     if (!array_key_exists($key, $array)) {
                         $array = null;
                         break;
                     }
                     $array = $array[$key];
                 }
                 if ($i == $j - 1) {
                     $return = $array;
                 }
             }
             if ($return !== null) {
                 return $return;
             }
         }
     } else {
         if (strpos($id, '.')) {
             $keys = explode('.', $id, 1);
             $mainId = array_shift($keys);
             if (array_key_exists($aroId . '_' . $mainId, MiCache::$_appSettingCache) && array_key_exists($id, MiCache::$_appSettingCache[$aroId . '_' . $mainId])) {
                 return MiCache::$_appSettingCache[$aroId . '_' . $mainId][$id];
             }
         }
     }
     if (MiCache::_hasSettingsTable()) {
         $return = MiCache::data('MiSettings.Setting', 'data', $id, $aroId);
         if ($return !== null) {
             return $return;
         }
     }
     $return = Configure::read($id);
     $cacheKey = MiCache::key(array('MiSettings.Setting', 'data', $id, $aroId));
     MiCache::write($cacheKey, $return, MiCache::$setting);
     return $return;
 }
Exemplo n.º 2
0
 /**
  * Write the cache only if it changed
  *
  * @return void
  * @access private
  */
 function __destruct()
 {
     if ($this->_change) {
         MiCache::write($this->_key, $this->_cache, 'Url');
     }
     if ($this->_changeGlobal) {
         MiCache::write('_global', $this->_cacheGlobal, 'Url');
     }
 }