当前位置: 首页>>代码示例>>PHP>>正文


PHP PEAR_Registry::channelExists方法代码示例

本文整理汇总了PHP中PEAR_Registry::channelExists方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::channelExists方法的具体用法?PHP PEAR_Registry::channelExists怎么用?PHP PEAR_Registry::channelExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PEAR_Registry的用法示例。


在下文中一共展示了PEAR_Registry::channelExists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isset

 /**
  * @param array dependency array
  * @access private
  */
 function _getDepPackageDownloadUrl($dep, $parr)
 {
     $xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
     $curchannel = $this->config->get('default_channel');
     if (isset($dep['uri'])) {
         $xsdversion = '2.0';
         $chan =& $this->_registry->getChannel('__uri');
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', '__uri');
         $this->configSet('default_channel', '__uri');
     } else {
         if (isset($dep['channel'])) {
             $remotechannel = $dep['channel'];
         } else {
             $remotechannel = 'pear.php.net';
         }
         if (!$this->_registry->channelExists($remotechannel)) {
             do {
                 if ($this->config->get('auto_discover')) {
                     if ($this->discover($remotechannel)) {
                         break;
                     }
                 }
                 return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
             } while (false);
         }
         $chan =& $this->_registry->getChannel($remotechannel);
         if (PEAR::isError($chan)) {
             return $chan;
         }
         $version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
         $this->configSet('default_channel', $remotechannel);
     }
     $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
     if (isset($parr['state']) && isset($parr['version'])) {
         unset($parr['state']);
     }
     if (isset($dep['uri'])) {
         $info =& $this->newDownloaderPackage($this);
         PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
         $err = $info->initialize($dep);
         PEAR::staticPopErrorHandling();
         if (!$err) {
             // skip parameters that were missed by preferred_state
             return PEAR::raiseError('Cannot initialize dependency');
         }
         if (PEAR::isError($err)) {
             if (!isset($this->_options['soft'])) {
                 $this->log(0, $err->getMessage());
             }
             if (is_object($info)) {
                 $param = $info->getChannel() . '/' . $info->getPackage();
             }
             return PEAR::raiseError('Package "' . $param . '" is not valid');
         }
         return $info;
     } elseif ($chan->supportsREST($this->config->get('preferred_mirror')) && (($base2 = $chan->getBaseURL('REST1.3', $this->config->get('preferred_mirror'))) || ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))))) {
         if ($base2) {
             $base = $base2;
             $rest =& $this->config->getREST('1.3', $this->_options);
         } else {
             $rest =& $this->config->getREST('1.0', $this->_options);
         }
         $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version, $chan->getName());
         if (PEAR::isError($url)) {
             return $url;
         }
         if ($parr['channel'] != $curchannel) {
             $this->configSet('default_channel', $curchannel);
         }
         if (!is_array($url)) {
             return $url;
         }
         $url['raw'] = false;
         // no checking is necessary for REST
         if (!is_array($url['info'])) {
             return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
         }
         if (isset($url['info']['required'])) {
             if (!class_exists('PEAR_PackageFile_v2')) {
                 require_once 'PEAR/PackageFile/v2.php';
             }
             $pf = new PEAR_PackageFile_v2();
             $pf->setRawChannel($remotechannel);
         } else {
             if (!class_exists('PEAR_PackageFile_v1')) {
                 require_once 'PEAR/PackageFile/v1.php';
             }
             $pf = new PEAR_PackageFile_v1();
         }
         $pf->setRawPackage($url['package']);
         $pf->setDeps($url['info']);
         if ($url['compatible']) {
             $pf->setCompatible($url['compatible']);
//.........这里部分代码省略.........
开发者ID:shen0834,项目名称:util,代码行数:101,代码来源:Downloader.php

示例3: isset

 /**
  * @param array dependency array
  * @access private
  */
 function _getDepPackageDownloadUrl($dep, $parr)
 {
     $xsdversion = isset($dep['rel']) ? '1.0' : '2.0';
     $curchannel = $this->config->get('default_channel');
     if (isset($dep['channel'])) {
         $remotechannel = $dep['channel'];
     } else {
         $remotechannel = 'pear.php.net';
     }
     if (!$this->_registry->channelExists($remotechannel)) {
         do {
             if ($this->config->get('auto_discover')) {
                 if ($this->discover($remotechannel)) {
                     break;
                 }
             }
             return PEAR::raiseError('Unknown remote channel: ' . $remotechannel);
         } while (false);
     }
     $this->configSet('default_channel', $remotechannel);
     $state = isset($parr['state']) ? $parr['state'] : $this->config->get('preferred_state');
     if (isset($parr['state']) && isset($parr['version'])) {
         unset($parr['state']);
     }
     $chan =& $this->_registry->getChannel($remotechannel);
     if (PEAR::isError($chan)) {
         return $chan;
     }
     $version = $this->_registry->packageInfo($dep['name'], 'version', $remotechannel);
     if ($chan->supportsREST($this->config->get('preferred_mirror')) && ($base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror')))) {
         $rest =& $this->config->getREST('1.0', $this->_options);
         $url = $rest->getDepDownloadURL($base, $xsdversion, $dep, $parr, $state, $version);
         if (PEAR::isError($url)) {
             return $url;
         }
         if ($parr['channel'] != $curchannel) {
             $this->configSet('default_channel', $curchannel);
         }
         if (!is_array($url)) {
             return $url;
         }
         $url['raw'] = false;
         // no checking is necessary for REST
         if (!is_array($url['info'])) {
             return PEAR::raiseError('Invalid remote dependencies retrieved from REST - ' . 'this should never happen');
         }
         if (isset($url['info']['required'])) {
             if (!class_exists('PEAR_PackageFile_v2')) {
                 require_once 'PEAR/PackageFile/v2.php';
             }
             $pf = new PEAR_PackageFile_v2();
             $pf->setRawChannel($remotechannel);
         } else {
             if (!class_exists('PEAR_PackageFile_v1')) {
                 require_once 'PEAR/PackageFile/v1.php';
             }
             $pf = new PEAR_PackageFile_v1();
         }
         $pf->setRawPackage($url['package']);
         $pf->setDeps($url['info']);
         $pf->setRawState($url['stability']);
         $url['info'] =& $pf;
         if (!extension_loaded("zlib") || isset($this->_options['nocompress'])) {
             $ext = '.tar';
         } else {
             $ext = '.tgz';
         }
         if (is_array($url)) {
             if (isset($url['url'])) {
                 $url['url'] .= $ext;
             }
         }
         return $url;
     } elseif ($chan->supports('xmlrpc', 'package.getDepDownloadURL', false, '1.1')) {
         if ($version) {
             $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state, $version);
         } else {
             $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
         }
     } else {
         $url = $this->_remote->call('package.getDepDownloadURL', $xsdversion, $dep, $parr, $state);
     }
     if ($parr['channel'] != $curchannel) {
         $this->configSet('default_channel', $curchannel);
     }
     if (!is_array($url)) {
         return $url;
     }
     if (isset($url['__PEAR_ERROR_CLASS__'])) {
         return PEAR::raiseError($url['message']);
     }
     $url['raw'] = $url['info'];
     $pkg =& $this->getPackagefileObject($this->config, $this->debug);
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     $pinfo =& $pkg->fromXmlString($url['info'], PEAR_VALIDATE_DOWNLOADING, 'remote');
     PEAR::staticPopErrorHandling();
//.........这里部分代码省略.........
开发者ID:soar-team,项目名称:kloxo,代码行数:101,代码来源:Downloader.php

示例4: install

 /**
  * Installs the files within the package file specified.
  *
  * @param string|PEAR_Downloader_Package $pkgfile path to the package file,
  *        or a pre-initialized packagefile object
  * @param array $options
  * recognized options:
  * - installroot   : optional prefix directory for installation
  * - force         : force installation
  * - register-only : update registry but don't install files
  * - upgrade       : upgrade existing install
  * - soft          : fail silently
  * - nodeps        : ignore dependency conflicts/missing dependencies
  * - alldeps       : install all dependencies
  * - onlyreqdeps   : install only required dependencies
  *
  * @return array|PEAR_Error package info if successful
  */
 function install($pkgfile, $options = array())
 {
     $this->_options = $options;
     $this->_registry =& $this->config->getRegistry();
     if (is_object($pkgfile)) {
         $dlpkg =& $pkgfile;
         $pkg = $pkgfile->getPackageFile();
         $pkgfile = $pkg->getArchiveFile();
         $descfile = $pkg->getPackageFile();
     } else {
         $descfile = $pkgfile;
         $pkg = $this->_parsePackageXml($descfile);
         if (PEAR::isError($pkg)) {
             return $pkg;
         }
     }
     $tmpdir = dirname($descfile);
     if (realpath($descfile) != realpath($pkgfile)) {
         // Use the temp_dir since $descfile can contain the download dir path
         $tmpdir = $this->config->get('temp_dir', null, 'pear.php.net');
         $tmpdir = System::mktemp('-d -t "' . $tmpdir . '"');
         $tar = new Archive_Tar($pkgfile);
         if (!$tar->extract($tmpdir)) {
             return $this->raiseError("unable to unpack {$pkgfile}");
         }
     }
     $pkgname = $pkg->getName();
     $channel = $pkg->getChannel();
     if (isset($this->_options['packagingroot'])) {
         $regdir = $this->_prependPath($this->config->get('php_dir', null, 'pear.php.net'), $this->_options['packagingroot']);
         $packrootphp_dir = $this->_prependPath($this->config->get('php_dir', null, $channel), $this->_options['packagingroot']);
     }
     if (isset($options['installroot'])) {
         $this->config->setInstallRoot($options['installroot']);
         $this->_registry =& $this->config->getRegistry();
         $installregistry =& $this->_registry;
         $this->installroot = '';
         // all done automagically now
         $php_dir = $this->config->get('php_dir', null, $channel);
     } else {
         $this->config->setInstallRoot(false);
         $this->_registry =& $this->config->getRegistry();
         if (isset($this->_options['packagingroot'])) {
             $installregistry = new PEAR_Registry($regdir);
             if (!$installregistry->channelExists($channel, true)) {
                 // we need to fake a channel-discover of this channel
                 $chanobj = $this->_registry->getChannel($channel, true);
                 $installregistry->addChannel($chanobj);
             }
             $php_dir = $packrootphp_dir;
         } else {
             $installregistry =& $this->_registry;
             $php_dir = $this->config->get('php_dir', null, $channel);
         }
         $this->installroot = '';
     }
     // {{{ checks to do when not in "force" mode
     if (empty($options['force']) && (file_exists($this->config->get('php_dir')) && is_dir($this->config->get('php_dir')))) {
         $testp = $channel == 'pear.php.net' ? $pkgname : array($channel, $pkgname);
         $instfilelist = $pkg->getInstallationFileList(true);
         if (PEAR::isError($instfilelist)) {
             return $instfilelist;
         }
         // ensure we have the most accurate registry
         $installregistry->flushFileMap();
         $test = $installregistry->checkFileMap($instfilelist, $testp, '1.1');
         if (PEAR::isError($test)) {
             return $test;
         }
         if (sizeof($test)) {
             $pkgs = $this->getInstallPackages();
             $found = false;
             foreach ($pkgs as $param) {
                 if ($pkg->isSubpackageOf($param)) {
                     $found = true;
                     break;
                 }
             }
             if ($found) {
                 // subpackages can conflict with earlier versions of parent packages
                 $parentreg = $installregistry->packageInfo($param->getPackage(), null, $param->getChannel());
                 $tmp = $test;
//.........这里部分代码省略.........
开发者ID:orcoliver,项目名称:oneye,代码行数:101,代码来源:Installer.php


注:本文中的PEAR_Registry::channelExists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。