本文整理汇总了PHP中PEAR_Installer::setUninstallPackages方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_Installer::setUninstallPackages方法的具体用法?PHP PEAR_Installer::setUninstallPackages怎么用?PHP PEAR_Installer::setUninstallPackages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_Installer
的用法示例。
在下文中一共展示了PEAR_Installer::setUninstallPackages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uninstallPlugin
/**
* Uninstalls a plugin.
*
* @param string $plugin The plugin name
* @param string $channel The channel name
*/
public function uninstallPlugin($plugin, $channel = null)
{
if (false !== strpos($plugin, '/')) {
list($channel, $plugin) = explode('/', $plugin);
}
$channel = is_null($channel) ? $this->environment->getConfig()->get('default_channel') : $channel;
$existing = $this->environment->getRegistry()->packageInfo($plugin, 'version', $channel);
if (is_null($existing)) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Plugin "%s" is not installed', $plugin))));
return false;
}
$this->dispatcher->notify(new sfEvent($this, 'plugin.pre_uninstall', array('channel' => $channel, 'plugin' => $plugin)));
$package = $this->environment->getRegistry()->parsePackageName($plugin, $channel);
$installer = new PEAR_Installer($this);
$packages = array($this->environment->getRegistry()->getPackage($plugin, $channel));
$installer->setUninstallPackages($packages);
$ret = $installer->uninstall($package);
if (PEAR::isError($ret)) {
throw new sfPluginException(sprintf('Problem uninstalling plugin "%s": %s', $plugin, $ret->getMessage()));
}
if ($ret) {
$this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Uninstallation successful for plugin "%s"', $plugin))));
$this->dispatcher->notify(new sfEvent($this, 'plugin.post_uninstall', array('channel' => $channel, 'plugin' => $plugin)));
} else {
throw new sfPluginException(sprintf('Uninstallation of "%s" plugin failed', $plugin));
}
return $ret;
}