Пример #1
0
/**
 * 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;
}