/** * Return a hash which refers to an entry in the db describing the files * * @see getFileString */ public static function getKey(array $files, $separator = ' ') { $content = self::getBase64($files, $separator); $key = sha1($content); $check = false; if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); $check = $cache->has($key); } else { $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir())); $check = $cache->has($key); } // Checks if key exists if (false === $check) { // now just doctrine if (!class_exists('sfCombine')) { throw new Exception('Call the task `doctrine:build-model` or use base64 url'); } $keyExists = Doctrine::getTable('sfCombine')->find($key); if (!$keyExists) { $combine = new sfCombine(); $combine->setAssetKey($key); $combine->setFiles($content); $combine->save(); } $cache->set($key, $content); } return $key; }
/** * Returns a key which combined all assets file * * @return string md5 */ function _get_key($files) { $content = base64_encode(serialize($files)); $key = md5($content . sfConfig::get('app_sfCombine_asset_version', '')); if (!class_exists('DbFinder')) { throw new Exception('sfCombine expects DbFinder to call combined asset file'); } $keyExists = DbFinder::from('sfCombine')->where('AssetsKey', $key)->count(); if (!$keyExists) { $combine = new sfCombine(); $combine->setAssetsKey($key); $combine->setFiles($content); $combine->save(); } // Checks if key exists if (!sfProcessCache::has($key)) { sfProcessCache::set($key, true); } return $key; }
/** * Returns a key which combined all assets file * * @return string md5 */ function _get_key($files) { $content = base64_encode(serialize($files)); $key = md5($content . sfConfig::get('app_sfCombinePlugin_asset_version', '')); if (!class_exists('DbFinder')) { throw new Exception('sfCombine expects DbFinder to call combined asset file'); } if (function_exists('apc_store') && ini_get('apc.enabled')) { $cache = new sfAPCCache(); // FIXME: APCCache "has" method doesn't work $checkFunction = apc_fetch($key); } else { $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir') . '/combiners')); $checkFunction = $cache->has($key); } // Checks if key exists if (false === $checkFunction) { $keyExists = DbFinder::from('sfCombine')->where('AssetsKey', $key)->count(); if (!$keyExists) { $combine = new sfCombine(); $combine->setAssetsKey($key); $combine->setFiles($content); $combine->save(); } $cache->set($key, true); } return $key; }