Mage_Connect_Packager::getRemoteCache PHP Method

getRemoteCache() public method

public getRemoteCache ( $ftpString )
    public function getRemoteCache($ftpString)
    {
        $ftpObj = new Mage_Connect_Ftp();
        $ftpObj->connect($ftpString);
        $remoteConfigExists = $ftpObj->fileExists("cache.cfg");
        if (!$remoteConfigExists) {
            $configFile = uniqid("temp_cachecfg_");
            $remoteCfg = new Mage_Connect_Singleconfig($configFile);
            $remoteCfg->clear();
            $ftpObj->upload("cache.cfg", $configFile);
        } else {
            $configFile = uniqid("temp_cachecfg_");
            $ftpObj->get($configFile, "cache.cfg");
            $remoteCfg = new Mage_Connect_Singleconfig($configFile);
        }
        return array($remoteCfg, $ftpObj);
    }

Usage Example

コード例 #1
0
 /**
  * Clear cache command callback
  * @param string $command
  * @param array $options
  * @param array $params
  * @return void
  */
 public function doClearCache($command, $options, $params)
 {
     $this->cleanupParams($params);
     try {
         $packager = new Mage_Connect_Packager();
         $ftp = empty($options['ftp']) ? false : $options['ftp'];
         if ($ftp) {
             list($cache, $ftpObj) = $packager->getRemoteCache($ftp);
             $cache->clear();
             $packager->writeToRemoteCache($cache, $ftpObj);
         } else {
             $cache = $this->getSconfig();
             $cache->clear();
         }
     } catch (Exception $e) {
         $this->doError($command, $e->getMessage());
     }
 }