當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PEAR_Config::getRemote方法代碼示例

本文整理匯總了PHP中PEAR_Config::getRemote方法的典型用法代碼示例。如果您正苦於以下問題:PHP PEAR_Config::getRemote方法的具體用法?PHP PEAR_Config::getRemote怎麽用?PHP PEAR_Config::getRemote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PEAR_Config的用法示例。


在下文中一共展示了PEAR_Config::getRemote方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: packageInfo

 /**
  * (non-PHPdoc)
  * @see lib/Faett/Core/Interfaces/Faett_Core_Interfaces_Service#packageInfo($packageName, $channel)
  */
 public function packageInfo($packageName, $channel)
 {
     // store the default channel
     $savechannel = $this->_config->get('default_channel');
     // check if the cannel already exists
     if ($this->_registry->channelExists($channel)) {
         $this->_config->set('default_channel', $channel);
     } else {
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelException::create('Channel ' . $channel . ' does not exist');
     }
     // load the channel from the registry
     $chan = $this->_registry->getChannel($channel);
     // initialize a REST command for checking the channel's state
     $cmd = new PEAR_Command_Remote($this->_ui, $this->_config);
     if (PEAR::isError($e = $cmd->_checkChannelForStatus($channel, $chan))) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_UnknownChannelStateException::create($e->getMessage());
     }
     // get the channel's base URL
     $base = $chan->getBaseURL('REST1.0', $this->_config->get('preferred_mirror'));
     // check if the channel's server is REST enabled
     $restSupport = $chan->supportsREST($this->_config->get('preferred_mirror'));
     // check if the channel is REST enabled
     if ($restSupport && $base) {
         // load the channel data and the package information
         $rest = $this->_config->getREST('1.0', array());
         $info = $rest->packageInfo($base, $packageName);
     } else {
         $r = $this->_config->getRemote();
         $info = $r->call('package.info', $packageName);
     }
     // check if the package information was loaded successfully
     if (PEAR::isError($info)) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create($info->getMessage());
     }
     // if no packge name was found log an error message
     if (!isset($info['name'])) {
         // reset the default channel
         $this->_config->set('default_channel', $savechannel);
         // throw a new exception
         throw Faett_Core_Exceptions_PackageInfoException::create('Can\'t find a package name');
     }
     // check if the package is installed
     $installed = $this->_registry->packageInfo($info['name'], null, $channel);
     // if yes, set the information
     $info['installed'] = $installed['version'] ? $installed['version'] : '';
     if (is_array($info['installed'])) {
         $info['installed'] = $info['installed']['release'];
     }
     // return the package information
     return $info;
 }
開發者ID:BGCX067,項目名稱:faett-core-svn-to-git,代碼行數:62,代碼來源:Service.php

示例2: getPackageInfo

 /**
  * Returns the latest information about the given package.
  *
  * @access protected
  * @return boolean   true on success, false on error
  * @since  0.4.0a1
  * @throws PEAR_PACKAGEUPDATE_ERROR_NOPACKAGE,
  *         PEAR_PACKAGEUPDATE_ERROR_NOCHANNEL,
  *         PEAR_PACKAGEUPDATE_ERROR_NOINFO
  */
 function getPackageInfo()
 {
     // Only check once.
     if (isset($this->latestVersion) && isset($this->info)) {
         return true;
     }
     // Make sure the channel and package are set.
     if (empty($this->packageName)) {
         $this->pushError(PEAR_PACKAGEUPDATE_ERROR_NOPACKAGE);
         return false;
     }
     if (empty($this->channel)) {
         $this->pushError(PEAR_PACKAGEUPDATE_ERROR_NOCHANNEL);
         return false;
     }
     // Create a config object.
     $config = new PEAR_Config();
     // Get the config's registry object.
     $reg = $config->getRegistry();
     // Parse the package name.
     $parsed = $reg->parsePackageName($this->channel . '/' . $this->packageName);
     // Check for errors.
     if (PEAR::isError($parsed)) {
         $this->pushError($parsed);
         return false;
     }
     // Get a PEAR_Remote instance.
     $r = $config->getRemote();
     // Get the package info.
     $info = $r->call('package.info', $parsed['package']);
     // Check to make sure the package was found.
     if (PEAR::isError($info)) {
         $this->pushError(PEAR_PACKAGEUPDATE_ERROR_NOINFO, NULL, array('packagename' => $this->packageName));
         return false;
     }
     // Get the installed version of the package.
     $this->instVersion = $reg->packageInfo($parsed['package'], 'version', $parsed['channel']);
     // If the package is not installed, create a dummy version.
     if (empty($this->instVersion)) {
         $this->instVersion = '0.0.0';
     }
     // Pull out the latest information.
     $this->latestVersion = reset(array_keys($info['releases']));
     $this->info = reset($info['releases']);
     return true;
 }
開發者ID:bjork,項目名稱:php-compat-info,代碼行數:56,代碼來源:source7813.php


注:本文中的PEAR_Config::getRemote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。