示例#1
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     // initialize database manager
     $databaseManager = new sfDatabaseManager($this->configuration);
     $flag = true;
     if (function_exists('apc_store') && ini_get('apc.enabled')) {
         $cache = new sfAPCCache();
         if (!ini_get('apc.enable_cli')) {
             $this->logSection('combine', 'Check apc.enable_cli in your ini file', null, 'ERROR');
             $flag = false;
         }
     } else {
         $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir()));
     }
     if ($flag) {
         if (!class_exists('sfCombine')) {
             $this->logSection('combine', 'Call the task `doctrine:build-model`', null, 'ERROR');
             return false;
         }
         $results = Doctrine::getTable('sfCombine')->findAll();
         foreach ($results as $result) {
             $cache->remove($result->getAssetKey());
         }
         $this->logSection('combine', 'Cleanup cache complete', null, 'INFO');
         $deleted = Doctrine::getTable('sfCombine')->deleteAll();
         $this->logSection('combine', sprintf('Cleanup database complete (%d rows deleted)', $deleted), null, 'INFO');
     }
 }
 /**
  * @see sfCombineUtility::getCacheDir()
  */
 public static function getCacheDir()
 {
     return sfCombineUtility::getCacheDir();
 }
示例#3
0
 /**
  * Take a db hash and convert it into an array of files
  *
  * @see getFiles
  */
 public static function getFilesByKey($key, $separator = ' ')
 {
     $base64 = false;
     // try get base64 from cache
     if (function_exists('apc_store') && ini_get('apc.enabled')) {
         $cache = new sfAPCCache();
         $base64 = $cache->get($key);
     }
     if (!$base64) {
         $cache = new sfFileCache(array('cache_dir' => sfCombineUtility::getCacheDir()));
         $base64 = $cache->get($key);
     }
     // check db
     if (!$base64 && class_exists('sfCombine')) {
         $combine = Doctrine::getTable('sfCombine')->find($key);
         $base64 = $combine ? $combine->getFiles() : false;
     }
     return self::getFilesByBase64($base64, $separator);
 }