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