本文整理汇总了PHP中PEAR_Registry::addPackage2方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::addPackage2方法的具体用法?PHP PEAR_Registry::addPackage2怎么用?PHP PEAR_Registry::addPackage2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Registry
的用法示例。
在下文中一共展示了PEAR_Registry::addPackage2方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: installBinary
/**
* Installation of source package has failed, attempt to download and install the
* binary version of this package.
* @param PEAR_Installer
* @return array|false
*/
function installBinary(&$installer)
{
if (!OS_WINDOWS) {
$a = false;
return $a;
}
if ($this->getPackageType() == 'extsrc') {
if (!is_array($installer->getInstallPackages())) {
$a = false;
return $a;
}
foreach ($installer->getInstallPackages() as $p) {
if ($p->isExtension($this->_packageInfo['providesextension'])) {
if ($p->getPackageType() != 'extsrc') {
$a = false;
return $a;
// the user probably downloaded it separately
}
}
}
if (isset($this->_packageInfo['extsrcrelease']['binarypackage'])) {
$installer->log(0, 'Attempting to download binary version of extension "' . $this->_packageInfo['providesextension'] . '"');
$params = $this->_packageInfo['extsrcrelease']['binarypackage'];
if (!is_array($params) || !isset($params[0])) {
$params = array($params);
}
if (isset($this->_packageInfo['channel'])) {
foreach ($params as $i => $param) {
$params[$i] = array('channel' => $this->_packageInfo['channel'], 'package' => $param, 'version' => $this->getVersion());
}
}
$dl =& $this->getPEARDownloader($installer->ui, $installer->getOptions(), $installer->config);
$verbose = $dl->config->get('verbose');
$dl->config->set('verbose', -1);
foreach ($params as $param) {
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$ret = $dl->download(array($param));
PEAR::popErrorHandling();
if (is_array($ret) && count($ret)) {
break;
}
}
$dl->config->set('verbose', $verbose);
if (is_array($ret)) {
if (count($ret) == 1) {
$pf = $ret[0]->getPackageFile();
PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
$err = $installer->install($ret[0]);
PEAR::popErrorHandling();
if (is_array($err)) {
$this->_packageInfo['#binarypackage'] = $ret[0]->getPackage();
// "install" self, so all dependencies will work transparently
$this->_registry->addPackage2($this);
$installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString(array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" successful');
$a = array($ret[0], $err);
return $a;
}
$installer->log(0, 'Download and install of binary extension "' . $this->_registry->parsedPackageNameToString(array('channel' => $pf->getChannel(), 'package' => $pf->getPackage()), true) . '" failed');
}
}
}
}
$a = false;
return $a;
}
示例2: install
//.........这里部分代码省略.........
if ($res->getMessage() == "file does not exist") {
$this->raiseError("file {$file} in package.xml does not exist");
}
return $this->raiseError($res);
}
if (!isset($options['soft'])) {
$this->log(0, "Warning: " . $res->getMessage());
}
}
$real = isset($atts['attribs']) ? $atts['attribs'] : $atts;
if ($res == PEAR_INSTALLER_OK && $real['role'] != 'src') {
// Register files that were installed
$pkg->installedFile($file, $atts);
}
}
// }}}
// {{{ compile and install source files
if ($this->source_files > 0 && empty($options['nobuild'])) {
if (PEAR::isError($err = $this->_compileSourceFiles($savechannel, $pkg))) {
return $err;
}
}
// }}}
if (isset($backedup)) {
$this->_removeBackups($backedup);
}
if (!$this->commitFileTransaction()) {
$this->rollbackFileTransaction();
$this->configSet('default_channel', $savechannel);
return $this->raiseError("commit failed", PEAR_INSTALLER_FAILED);
}
// }}}
$ret = false;
$installphase = 'install';
$oldversion = false;
// {{{ Register that the package is installed -----------------------
if (empty($options['upgrade'])) {
// if 'force' is used, replace the info in registry
$usechannel = $channel;
if ($channel == 'pecl.php.net') {
$test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
$test = $installregistry->packageExists($pkgname, 'pear.php.net');
$usechannel = 'pear.php.net';
}
} else {
$test = $installregistry->packageExists($pkgname, $channel);
}
if (!empty($options['force']) && $test) {
$oldversion = $installregistry->packageInfo($pkgname, 'version', $usechannel);
$installregistry->deletePackage($pkgname, $usechannel);
}
$ret = $installregistry->addPackage2($pkg);
} else {
if ($dirtree) {
$this->startFileTransaction();
// attempt to delete empty directories
uksort($dirtree, array($this, '_sortDirs'));
foreach ($dirtree as $dir => $notused) {
$this->addFileOperation('rmdir', array($dir));
}
$this->commitFileTransaction();
}
$usechannel = $channel;
if ($channel == 'pecl.php.net') {
$test = $installregistry->packageExists($pkgname, $channel);
if (!$test) {
$test = $installregistry->packageExists($pkgname, 'pear.php.net');
$usechannel = 'pear.php.net';
}
} else {
$test = $installregistry->packageExists($pkgname, $channel);
}
// new: upgrade installs a package if it isn't installed
if (!$test) {
$ret = $installregistry->addPackage2($pkg);
} else {
if ($usechannel != $channel) {
$installregistry->deletePackage($pkgname, $usechannel);
$ret = $installregistry->addPackage2($pkg);
} else {
$ret = $installregistry->updatePackage2($pkg);
}
$installphase = 'upgrade';
}
}
if (!$ret) {
$this->configSet('default_channel', $savechannel);
return $this->raiseError("Adding package {$channel}/{$pkgname} to registry failed");
}
// }}}
$this->configSet('default_channel', $savechannel);
if (class_exists('PEAR_Task_Common')) {
// this is auto-included if any tasks exist
if (PEAR_Task_Common::hasPostinstallTasks()) {
PEAR_Task_Common::runPostinstallTasks($installphase);
}
}
return $pkg->toArray(true);
}