本文整理汇总了PHP中PEAR_PackageFileManager2::addPostInstallTask方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFileManager2::addPostInstallTask方法的具体用法?PHP PEAR_PackageFileManager2::addPostInstallTask怎么用?PHP PEAR_PackageFileManager2::addPostInstallTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_PackageFileManager2
的用法示例。
在下文中一共展示了PEAR_PackageFileManager2::addPostInstallTask方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
//.........这里部分代码省略.........
}
if ($this->_dependencies->pear !== false) {
$package->setPearinstallerDep($this->_dependencies->pear->minimum_version, $this->_dependencies->pear->maximum_version, $this->_dependencies->pear->recommended_version, $this->_dependencies->pear->exclude_version);
} else {
$package->setPearinstallerDep(PEAR_Config::singleton()->getRegistry()->packageInfo('PEAR', 'version'));
}
foreach ($this->_maintainers as $maintainer) {
$package->addMaintainer($maintainer->role, $maintainer->user, $maintainer->name, $maintainer->email, $maintainer->active);
}
// handle dependencies
if (!empty($this->_dependencies)) {
$this->log('adding dependencies');
if (count($this->_dependencies->groups) > 0) {
$this->log('found dependency groups');
foreach ($this->_dependencies->groups as $group) {
$this->log("adding [{$group->name}] :: [{$group->hint}]");
$package->addDependencyGroup($group->name, $group->hint);
foreach ($group->packages as $sub_package) {
$package->addGroupPackageDepWithChannel('subpackage', $group->name, $sub_package->name, $sub_package->channel, '0.0.1');
}
}
}
if (count($this->_dependencies->packages) > 0) {
$this->log('found dependencies');
foreach ($this->_dependencies->packages as $dependency) {
$this->log("adding following dependency: {$dependency->channel}/{$dependency->name}");
$package->addPackageDepWithChannel($dependency->type, $dependency->name, $dependency->channel, $dependency->minimum_version, $dependency->maximum_version, $dependency->recommended_version, $dependency->exclude_version, $dependency->providesextension, $dependency->nodefault);
}
}
if (count($this->_dependencies->extensions) > 0) {
$this->log('adding extension dependencies');
foreach ($this->_dependencies->extensions as $extension) {
$this->log("adding ext dependency for: {$extension->name}");
$package->addExtensionDep($extension->type, $extension->name, $extension->minimum_version, $extension->maximum_version, $extension->recommended_version, $extension->extension);
}
}
}
foreach ($this->_changelogs as $changelog) {
$this->log("adding changelog for prior release [{$changelog->version}]");
$changelog->package = $package;
$package->setChangelogEntry($changelog->version, $changelog->toArray());
if (is_null($this->_notes) && $package->getVersion() == $changelog->version) {
$this->log("no package notes specified, using changelog entry");
$this->_notes = $changelog->contents;
}
}
foreach ($this->_replacements as $replacement) {
$replacement->isValid();
$package->addReplacement($replacement->path, $replacement->type, $replacement->from, $replacement->to);
}
foreach ($this->_globalreplacements as $replacement) {
$replacement->isValid();
$this->log("adding global repalcement: {$replacement->from}");
$package->addGlobalReplacement($replacement->type, $replacement->from, $replacement->to);
}
foreach ($this->_releases as $release) {
$this->log('adding new release');
$package->addRelease();
foreach ($release->install as $install) {
$this->log("installing [{$install->name}] as [{$install->as}]");
$package->addInstallAs($install->name, $install->as);
}
}
$notes = preg_replace("/^( {4}|\t)+/m", '', $this->_notes->__toString());
$package->setNotes($notes);
$package->setLicense($this->_license->license, $this->_license->uri);
// handle PostInstallation
if (!empty($this->_postinstalls)) {
foreach ($this->_postinstalls as $postInstall) {
$postInstallScript = $package->initPostinstallScript($postInstall->script);
$this->log('adding post installation for script : ' . $postInstall->script);
foreach ($postInstall->paramgroups as $paramGroup) {
$this->log('adding parameter group' . $paramGroup->name);
$instructions = $paramGroup->instructions;
if (empty($instructions)) {
$instructions = false;
}
$params = array();
foreach ($paramGroup->params as $param) {
$this->log('adding parameter ' . $param->name);
$params[] = $postInstallScript->getParam($param->name, $param->prompt, $param->type, $param->default);
}
if (empty($params)) {
$params = false;
}
$postInstallScript->addParamGroup($paramGroup->name, $params, $instructions);
}
$e = $package->addPostInstallTask($postInstallScript, $postInstall->script);
if (PEAR::isError($e)) {
throw new d51PearPkg2Task_Exception('unable to add post install task: ' . $e->getMessage());
}
$this->log('Added POSTINSTALL for ' . $postInstall->script);
}
}
$package->generateContents();
$e = $package->writePackageFile();
if (PEAR::isError($e)) {
throw new d51PearPkg2Task_Exception('unable to write package.xml file: ' . $e->getMessage());
}
}