本文整理匯總了PHP中PEAR_PackageFile_v1::setConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP PEAR_PackageFile_v1::setConfig方法的具體用法?PHP PEAR_PackageFile_v1::setConfig怎麽用?PHP PEAR_PackageFile_v1::setConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PEAR_PackageFile_v1
的用法示例。
在下文中一共展示了PEAR_PackageFile_v1::setConfig方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: foreach
function _convertPackage($packagexml)
{
$pkg =& $this->getPackageFile($this->config);
$pf2 =& $pkg->fromPackageFile($packagexml, PEAR_VALIDATE_NORMAL);
if (!is_a($pf2, 'PEAR_PackageFile_v2')) {
return $this->raiseError('Cannot process "' . $packagexml . '", is not a package.xml 2.0');
}
require_once 'PEAR/PackageFile/v1.php';
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->config);
if ($pf2->getPackageType() != 'extsrc' && $pf2->getPackageType() != 'zendextsrc') {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", is not an extension source package. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (is_array($pf2->getUsesRole())) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom roles. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
}
if (is_array($pf2->getUsesTask())) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains custom tasks. Using a PEAR_PackageFileManager-based script or ' . 'the convert command is an option');
}
$deps = $pf2->getDependencies();
if (isset($deps['group'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains dependency groups. Using a PEAR_PackageFileManager-based script ' . 'or the convert command is an option');
}
if (isset($deps['required']['subpackage']) || isset($deps['optional']['subpackage'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains subpackage dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (isset($deps['required']['os'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains os dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
if (isset($deps['required']['arch'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '", contains arch dependencies. Using a PEAR_PackageFileManager-based ' . 'script is an option');
}
$pf->setPackage($pf2->getPackage());
$pf->setSummary($pf2->getSummary());
$pf->setDescription($pf2->getDescription());
foreach ($pf2->getMaintainers() as $maintainer) {
$pf->addMaintainer($maintainer['role'], $maintainer['handle'], $maintainer['name'], $maintainer['email']);
}
$pf->setVersion($pf2->getVersion());
$pf->setDate($pf2->getDate());
$pf->setLicense($pf2->getLicense());
$pf->setState($pf2->getState());
$pf->setNotes($pf2->getNotes());
$pf->addPhpDep($deps['required']['php']['min'], 'ge');
if (isset($deps['required']['php']['max'])) {
$pf->addPhpDep($deps['required']['php']['max'], 'le');
}
if (isset($deps['required']['package'])) {
if (!isset($deps['required']['package'][0])) {
$deps['required']['package'] = array($deps['required']['package']);
}
foreach ($deps['required']['package'] as $dep) {
if (!isset($dep['channel'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains dependency on a non-standard channel package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['conflicts'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['exclude'])) {
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
}
if (isset($dep['min'])) {
$pf->addPackageDep($dep['name'], $dep['min'], 'ge');
}
if (isset($dep['max'])) {
$pf->addPackageDep($dep['name'], $dep['max'], 'le');
}
}
}
if (isset($deps['required']['extension'])) {
if (!isset($deps['required']['extension'][0])) {
$deps['required']['extension'] = array($deps['required']['extension']);
}
foreach ($deps['required']['extension'] as $dep) {
if (isset($dep['conflicts'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains conflicts dependency. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if (isset($dep['exclude'])) {
$this->ui->outputData('WARNING: exclude tags are ignored in conversion');
}
if (isset($dep['min'])) {
$pf->addExtensionDep($dep['name'], $dep['min'], 'ge');
}
if (isset($dep['max'])) {
$pf->addExtensionDep($dep['name'], $dep['max'], 'le');
}
}
}
if (isset($deps['optional']['package'])) {
if (!isset($deps['optional']['package'][0])) {
$deps['optional']['package'] = array($deps['optional']['package']);
}
foreach ($deps['optional']['package'] as $dep) {
if (!isset($dep['channel'])) {
return $this->raiseError('Cannot safely convert "' . $packagexml . '"' . ' contains uri-based dependency on a package. Using a ' . 'PEAR_PackageFileManager-based script is an option');
}
if ($dep['channel'] != 'pear.php.net' && $dep['channel'] != 'pecl.php.net') {
//.........這裏部分代碼省略.........
示例2: updatePackage
function updatePackage($package, $info, $merge = true)
{
if (is_object($info)) {
return $this->updatePackage2($info, $merge);
}
if (PEAR::isError($e = $this->_lock(LOCK_EX))) {
return $e;
}
$ret = $this->_updatePackage($package, $info, $merge);
$this->_unlock();
if ($ret) {
if (!class_exists('PEAR_PackageFile_v1')) {
require_once 'PEAR/PackageFile/v1.php';
}
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->_config);
$pf->fromArray($this->packageInfo($package));
$this->_dependencyDB->uninstallPackage($pf);
$this->_dependencyDB->installPackage($pf);
}
return $ret;
}
示例3: parse
/**
* @param string contents of package.xml file, version 1.0
* @return bool success of parsing
*/
function parse($data, $file, $archive = false)
{
if (!extension_loaded('xml')) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml, no xml extension');
}
$xp = @xml_parser_create();
if (!$xp) {
return PEAR::raiseError('Cannot create xml parser for parsing package.xml');
}
xml_set_object($xp, $this);
xml_set_element_handler($xp, '_element_start_1_0', '_element_end_1_0');
xml_set_character_data_handler($xp, '_pkginfo_cdata_1_0');
xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
$this->element_stack = array();
$this->_packageInfo = array('provides' => array());
$this->current_element = false;
unset($this->dir_install);
$this->_packageInfo['filelist'] = array();
$this->filelist =& $this->_packageInfo['filelist'];
$this->dir_names = array();
$this->in_changelog = false;
$this->d_i = 0;
$this->cdata = '';
$this->_isValid = true;
if (!xml_parse($xp, $data, 1)) {
$code = xml_get_error_code($xp);
$line = xml_get_current_line_number($xp);
xml_parser_free($xp);
return PEAR::raiseError(sprintf("XML error: %s at line %d", $str = xml_error_string($code), $line), 2);
}
xml_parser_free($xp);
$pf = new PEAR_PackageFile_v1();
$pf->setConfig($this->_config);
if (isset($this->_logger)) {
$pf->setLogger($this->_logger);
}
$pf->setPackagefile($file, $archive);
$pf->fromArray($this->_packageInfo);
return $pf;
}