本文整理汇总了PHP中PEAR_Registry::parsePackageName方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Registry::parsePackageName方法的具体用法?PHP PEAR_Registry::parsePackageName怎么用?PHP PEAR_Registry::parsePackageName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Registry
的用法示例。
在下文中一共展示了PEAR_Registry::parsePackageName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: validatePackageUninstall
//.........这里部分代码省略.........
}
}
// next remove any packages from the parents list that are not passed in for
// uninstallation
foreach ($allparents as $parent => $d1) {
foreach ($d1 as $d) {
foreach ($params as $param) {
if (strtolower($param->getChannel()) == $d[0][0]['channel'] && strtolower($param->getPackage()) == $d[0][0]['package']) {
// found it
continue 3;
}
}
$remove[$parent] = true;
}
}
// remove all packages whose dependencies fail
// save which ones failed for error reporting
$badchildren = array();
do {
$fail = false;
foreach ($remove as $package => $unused) {
if (!isset($allparents[$package])) {
continue;
}
foreach ($allparents[$package] as $kid => $d1) {
foreach ($d1 as $depinfo) {
if ($depinfo[1]['type'] != 'optional') {
if (isset($badchildren[$kid])) {
continue;
}
$badchildren[$kid] = true;
$remove[$kid] = true;
$fail = true;
continue 2;
}
}
}
if ($fail) {
// start over, we removed some children
continue 2;
}
}
} while ($fail);
// next, construct the list of packages that can't be uninstalled
$badpackages = array();
$save = $this->_currentPackage;
foreach ($perpackagelist as $package => $packagedeps) {
foreach ($packagedeps as $parent) {
if (!isset($remove[$parent[0]])) {
continue;
}
$packagename = $this->_registry->parsePackageName($parent[0]);
$packagename['channel'] = $this->_registry->channelAlias($packagename['channel']);
$pa = $this->_registry->getPackage($packagename['package'], $packagename['channel']);
$packagename['package'] = $pa->getPackage();
$this->_currentPackage = $packagename;
// parent is not present in uninstall list, make sure we can actually
// uninstall it (parent dep is optional)
$parentname['channel'] = $this->_registry->channelAlias($parent[1]['dep']['channel']);
$pa = $this->_registry->getPackage($parent[1]['dep']['name'], $parent[1]['dep']['channel']);
$parentname['package'] = $pa->getPackage();
$parent[1]['dep']['package'] = $parentname['package'];
$parent[1]['dep']['channel'] = $parentname['channel'];
if ($parent[1]['type'] == 'optional') {
$test = $this->_validatePackageUninstall($parent[1]['dep'], false, $dl);
if ($test !== true) {
$badpackages[$package]['warnings'][] = $test;
}
} else {
$test = $this->_validatePackageUninstall($parent[1]['dep'], true, $dl);
if ($test !== true) {
$badpackages[$package]['errors'][] = $test;
}
}
}
}
$this->_currentPackage = $save;
$dl->___uninstall_package_cache = $badpackages;
if (isset($badpackages[$memyselfandI])) {
if (isset($badpackages[$memyselfandI]['warnings'])) {
foreach ($badpackages[$memyselfandI]['warnings'] as $warning) {
$dl->log(0, $warning[0]);
}
}
if (isset($badpackages[$memyselfandI]['errors'])) {
foreach ($badpackages[$memyselfandI]['errors'] as $error) {
if (is_array($error)) {
$dl->log(0, $error[0]);
} else {
$dl->log(0, $error->getMessage());
}
}
if (isset($this->_options['nodeps']) || isset($this->_options['force'])) {
return $this->warning('warning: %s should not be uninstalled, other installed packages depend ' . 'on this package');
}
return $this->raiseError('%s cannot be uninstalled, other installed packages depend on this package');
}
}
return true;
}