本文整理汇总了PHP中Mage_Connect_Package::importDataV1x方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Connect_Package::importDataV1x方法的具体用法?PHP Mage_Connect_Package::importDataV1x怎么用?PHP Mage_Connect_Package::importDataV1x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Connect_Package
的用法示例。
在下文中一共展示了Mage_Connect_Package::importDataV1x方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doSyncPear
/**
* Synchronize packages installed earlier (by pear installer) with local cache
*
* @param string $command
* @param array $options
* @param array $params
*/
public function doSyncPear($command, $options, $params)
{
$this->cleanupParams($params);
try {
$packager = $this->getPackager();
$cache = null;
$config = null;
$ftpObj = null;
$ftp = empty($options['ftp']) ? false : $options['ftp'];
if ($ftp) {
list($cache, $config, $ftpObj) = $packager->getRemoteConf($ftp);
} else {
$config = $this->config();
$cache = $this->getSconfig();
}
$pkglist = array();
if (!$this->_checkPearData($config)) {
return $pkglist;
}
$pearStorage = $config->magento_root . DS . $config->downloader_path . DS . self::PACKAGE_PEAR_DIR;
$channels = array('.channel.connect.magentocommerce.com_community', '.channel.connect.magentocommerce.com_core');
foreach ($channels as $channel) {
$channelDirectory = $pearStorage . DS . $channel;
if (!file_exists($channelDirectory) || !is_dir($channelDirectory)) {
continue;
}
$dp = opendir($channelDirectory);
if (!$dp) {
continue;
}
while ($ent = readdir($dp)) {
if ($ent[0] == '.' || substr($ent, -4) != '.reg') {
continue;
}
$pkglist[] = array('file' => $ent, 'channel' => $channel);
}
closedir($dp);
}
$package = new Mage_Connect_Package();
foreach ($pkglist as $pkg) {
$pkgFilename = $pearStorage . DS . $pkg['channel'] . DS . $pkg['file'];
if (!file_exists($pkgFilename)) {
continue;
}
$data = file_get_contents($pkgFilename);
$data = unserialize($data);
$package->importDataV1x($data);
$name = $package->getName();
$channel = $package->getChannel();
$version = $package->getVersion();
if (!$cache->isChannel($channel) && $channel == $config->root_channel) {
$cache->addChannel($channel, $config->root_channel_uri);
}
if (!$cache->hasPackage($channel, $name, $version, $version)) {
$cache->addPackage($package);
if ($ftp) {
$localXml = tempnam(sys_get_temp_dir(), 'package');
@file_put_contents($localXml, $package->getPackageXml());
if (is_file($localXml)) {
$ftpDir = $ftpObj->getcwd();
$remoteXmlPath = $ftpDir . '/' . Mage_Connect_Package::PACKAGE_XML_DIR;
$remoteXml = $package->getReleaseFilename() . '.xml';
$ftpObj->mkdirRecursive($remoteXmlPath);
$ftpObj->upload($remoteXml, $localXml, 0777, 0666);
$ftpObj->chdir($ftpDir);
}
} else {
$destDir = rtrim($config->magento_root, "\\/") . DS . Mage_Connect_Package::PACKAGE_XML_DIR;
$destFile = $package->getReleaseFilename() . '.xml';
$dest = $destDir . DS . $destFile;
@mkdir($destDir, 0777, true);
@file_put_contents($dest, $package->getPackageXml());
@chmod($dest, 0666);
}
$this->ui()->output("Successfully added: {$channel}/{$name}-{$version}");
}
}
$config->sync_pear = true;
if ($ftp) {
$packager->writeToRemoteCache($cache, $ftpObj);
@unlink($config->getFilename());
}
} catch (Exception $e) {
$this->doError($command, $e->getMessage());
}
return true;
}