當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PEAR_Dependency2::validatePackageUninstall方法代碼示例

本文整理匯總了PHP中PEAR_Dependency2::validatePackageUninstall方法的典型用法代碼示例。如果您正苦於以下問題:PHP PEAR_Dependency2::validatePackageUninstall方法的具體用法?PHP PEAR_Dependency2::validatePackageUninstall怎麽用?PHP PEAR_Dependency2::validatePackageUninstall使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PEAR_Dependency2的用法示例。


在下文中一共展示了PEAR_Dependency2::validatePackageUninstall方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: uninstall

 /**
  * Uninstall a package
  *
  * This method removes all files installed by the application, and then
  * removes any empty directories.
  * @param string package name
  * @param array Command-line options.  Possibilities include:
  *
  *              - installroot: base installation dir, if not the default
  *              - register-only : update registry but don't remove files
  *              - nodeps: do not process dependencies of other packages to ensure
  *                        uninstallation does not break things
  */
 function uninstall($package, $options = array())
 {
     $installRoot = isset($options['installroot']) ? $options['installroot'] : '';
     $this->config->setInstallRoot($installRoot);
     $this->installroot = '';
     $this->_registry =& $this->config->getRegistry();
     if (is_object($package)) {
         $channel = $package->getChannel();
         $pkg = $package;
         $package = $pkg->getPackage();
     } else {
         $pkg = false;
         $info = $this->_registry->parsePackageName($package, $this->config->get('default_channel'));
         $channel = $info['channel'];
         $package = $info['package'];
     }
     $savechannel = $this->config->get('default_channel');
     $this->configSet('default_channel', $channel);
     if (!is_object($pkg)) {
         $pkg = $this->_registry->getPackage($package, $channel);
     }
     if (!$pkg) {
         $this->configSet('default_channel', $savechannel);
         return $this->raiseError($this->_registry->parsedPackageNameToString(array('channel' => $channel, 'package' => $package), true) . ' not installed');
     }
     if ($pkg->getInstalledBinary()) {
         // this is just an alias for a binary package
         return $this->_registry->deletePackage($package, $channel);
     }
     $filelist = $pkg->getFilelist();
     PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN);
     if (!class_exists('PEAR_Dependency2')) {
         require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/Dependency2.php';
     }
     $depchecker = new PEAR_Dependency2($this->config, $options, array('channel' => $channel, 'package' => $package), PEAR_VALIDATE_UNINSTALLING);
     $e = $depchecker->validatePackageUninstall($this);
     PEAR::staticPopErrorHandling();
     if (PEAR::isError($e)) {
         if (!isset($options['ignore-errors'])) {
             return $this->raiseError($e);
         }
         if (!isset($options['soft'])) {
             $this->log(0, 'WARNING: ' . $e->getMessage());
         }
     } elseif (is_array($e)) {
         if (!isset($options['soft'])) {
             $this->log(0, $e[0]);
         }
     }
     $this->pkginfo =& $pkg;
     // pretty much nothing happens if we are only registering the uninstall
     if (empty($options['register-only'])) {
         // {{{ Delete the files
         $this->startFileTransaction();
         PEAR::pushErrorHandling(PEAR_ERROR_RETURN);
         if (PEAR::isError($err = $this->_deletePackageFiles($package, $channel))) {
             PEAR::popErrorHandling();
             $this->rollbackFileTransaction();
             $this->configSet('default_channel', $savechannel);
             if (!isset($options['ignore-errors'])) {
                 return $this->raiseError($err);
             }
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: ' . $err->getMessage());
             }
         } else {
             PEAR::popErrorHandling();
         }
         if (!$this->commitFileTransaction()) {
             $this->rollbackFileTransaction();
             if (!isset($options['ignore-errors'])) {
                 return $this->raiseError("uninstall failed");
             }
             if (!isset($options['soft'])) {
                 $this->log(0, 'WARNING: uninstall failed');
             }
         } else {
             $this->startFileTransaction();
             $dirtree = $pkg->getDirTree();
             if ($dirtree === false) {
                 $this->configSet('default_channel', $savechannel);
                 return $this->_registry->deletePackage($package, $channel);
             }
             // attempt to delete empty directories
             uksort($dirtree, array($this, '_sortDirs'));
             foreach ($dirtree as $dir => $notused) {
                 $this->addFileOperation('rmdir', array($dir));
//.........這裏部分代碼省略.........
開發者ID:orcoliver,項目名稱:oneye,代碼行數:101,代碼來源:Installer.php


注:本文中的PEAR_Dependency2::validatePackageUninstall方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。