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


PHP PEAR_Downloader::discover方法代碼示例

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


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

示例1:

 /**
  *
  * @param string|array pass in an array of format
  *                     array(
  *                      'package' => 'pname',
  *                     ['channel' => 'channame',]
  *                     ['version' => 'version',]
  *                     ['state' => 'state',])
  *                     or a string of format [channame/]pname[-version|-state]
  */
 function _fromString($param)
 {
     $options = $this->_downloader->getOptions();
     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
     $pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
     PEAR::popErrorHandling();
     if (PEAR::isError($pname)) {
         if ($pname->getCode() == 'invalid') {
             $this->_valid = false;
             return false;
         }
         if ($pname->getCode() == 'channel') {
             $parsed = $pname->getUserInfo();
             if ($this->_downloader->discover($parsed['channel'])) {
                 if ($this->_config->get('auto_discover')) {
                     PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
                     $pname = $this->_registry->parsePackageName($param, $this->_config->get('default_channel'));
                     PEAR::popErrorHandling();
                 } else {
                     if (!isset($options['soft'])) {
                         $this->_downloader->log(0, 'Channel "' . $parsed['channel'] . '" is not initialized, use ' . '"pear channel-discover ' . $parsed['channel'] . '" to initialize' . 'or pear config-set auto_discover 1');
                     }
                 }
             }
             if (PEAR::isError($pname)) {
                 if (!isset($options['soft'])) {
                     $this->_downloader->log(0, $pname->getMessage());
                 }
                 if (is_array($param)) {
                     $param = $this->_registry->parsedPackageNameToString($param);
                 }
                 $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
                 $this->_valid = false;
                 return $err;
             }
         } else {
             if (!isset($options['soft'])) {
                 $this->_downloader->log(0, $pname->getMessage());
             }
             $err = PEAR::raiseError('invalid package name/package file "' . $param . '"');
             $this->_valid = false;
             return $err;
         }
     }
     if (!isset($this->_type)) {
         $this->_type = 'xmlrpc';
     }
     $this->_parsedname = $pname;
     if (isset($pname['state'])) {
         $this->_explicitState = $pname['state'];
     } else {
         $this->_explicitState = false;
     }
     if (isset($pname['group'])) {
         $this->_explicitGroup = true;
     } else {
         $this->_explicitGroup = false;
     }
     $info = $this->_downloader->_getPackageDownloadUrl($pname);
     if (PEAR::isError($info)) {
         if ($pname['channel'] == 'pear.php.net') {
             // try pecl
             $pname['channel'] = 'pecl.php.net';
             if ($test = $this->_downloader->_getPackageDownloadUrl($pname)) {
                 if (!PEAR::isError($test)) {
                     $info = PEAR::raiseError($info->getMessage() . ' - package ' . $this->_registry->parsedPackageNameToString($pname, true) . ' can be installed with "pecl install ' . $pname['package'] . '"');
                 }
             }
         }
         return $info;
     }
     $this->_rawpackagefile = $info['raw'];
     $ret = $this->_analyzeDownloadURL($info, $param, $pname);
     if (PEAR::isError($ret)) {
         return $ret;
     }
     if ($ret) {
         $this->_downloadURL = $ret;
         return $this->_valid = (bool) $ret;
     }
 }
開發者ID:hbustun,項目名稱:agilebill,代碼行數:91,代碼來源:Package.php


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