uninstall an extension

@access public
@author Jerome Bogaerts, <jerome@taotesting.com>
@return boolean
175327
public function uninstall()
	{
		
		common_Logger::i('Uninstalling '.$this->extension->getId(), 'UNINSTALL');

		// uninstall possible
    	if (is_null($this->extension->getManifest()->getUninstallData())) {
			throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() .' : Uninstall not supported');
		}
		
		// installed? 
		if (!common_ext_ExtensionsManager::singleton()->isInstalled($this->extension->getId())) {
			throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() .' : Not installed');
		}
		
		// check dependcies
		if (helpers_ExtensionHelper::isRequired($this->extension)) {
		    throw new common_Exception('Problem uninstalling extension ' . $this->extension->getId() .' : Still required');
		};

		common_Logger::d('uninstall script for ' . $this->extension->getId());
		$this->uninstallScripts();
		
		// hook
		$this->extendedUninstall();
		
		common_Logger::d('unregister extension ' . $this->extension->getId());
		$this->unregister();
		
		// we purge the whole cache.
		$cache = common_cache_FileCache::singleton();
		$cache->purge();
		
		common_Logger::i('Uninstalled ' . $this->extension->getId());
		return true;
	}
527439
public function cmdUninstallModule()
    {
        $result = $this->module_model->uninstall($this->getParam(0));

        if ($result !== true) {
            $this->errorAndExit($result);
        }

        $this->output();
    }
802428
private void uninstallModule(ModuleIdentifier modID) {
    File modDir = new File(modRoot, modID.toString());
    if (modDir.exists()) {
      modDir.delete();
    }
  }
1109981
public function ext()
    {
        if (!$this->info) {
            $this->info();
        }
        if (isset($this->info['extension'])) {
            return $this->info['extension'];
        }

        return false;
    }
452588
protected function _uninstall()
    {
        $allThemes = plugin()
            ->filter(function ($plugin) {
                return $plugin->isTheme;
            })
            ->toArray();
        $index = 1;
        $this->out();
        foreach ($allThemes as $plugin) {
            $allThemes[$index] = $plugin;
            $this->out(__d('installer', '[{0, number}] {1}', [$index, $plugin->humanName]));
            $index++;
        }
        $this->out();

        $message = __d('installer', "Which theme would you like to uninstall?\n[Q]uit");
        while (true) {
            $in = trim($this->in($message));
            if (strtoupper($in) === 'Q') {
                $this->err(__d('installer', 'Operation aborted'));
                break;
            } elseif (intval($in) < 1 || !isset($allThemes[intval($in)])) {
                $this->err(__d('installer', 'Invalid option'));
            } else {
                $plugin = plugin($allThemes[$in]->name());
                $this->hr();
                $this->out(__d('installer', '<info>The following theme will be uninstalled</info>'));
                $this->hr();
                $this->out(__d('installer', 'Name:        {0}', $plugin->name));
                $this->out(__d('installer', 'Description: {0}', $plugin->composer['description']));
                $this->out(__d('installer', 'Path:        {0}', $plugin->path));
                $this->hr();
                $this->out();

                $confirm = $this->in(__d('installer', 'Please type in "{0}" to uninstall', $allThemes[$in]->name));
                if ($confirm === $allThemes[$in]->name) {
                    $task = $this->dispatchShell("Installer.plugins uninstall -p {$allThemes[$in]->name}");

                    if ($task === 0) {
                        $this->out(__d('installer', 'Plugin uninstalled!'));
                        Plugin::dropCache();
                    } else {
                        $this->err(__d('installer', 'Plugin could not be uninstalled.'), 2);
                        $this->out();
                    }
                } else {
                    $this->err(__d('installer', 'Confirmation failure, operation aborted!'));
                }
                break;
            }
        }

        $this->out();
    }
895320
public function uninstall_language($lang) {
        global $CFG;

        $dest1 = $CFG->dataroot.'/lang/'.$lang;
        $dest2 = $CFG->dirroot.'/lang/'.$lang;
        $rm1 = false;
        $rm2 = false;
        if (file_exists($dest1)) {
            $rm1 = remove_dir($dest1);
        }
        if (file_exists($dest2)) {
            $rm2 = remove_dir($dest2);
        }

        if ($rm1 or $rm2) {
            $this->info[] = get_string('langpackremoved', 'tool_langimport', $lang);
            event\langpack_removed::event_with_langcode($lang)->trigger();
            return true;
        } else {    // Nothing deleted, possibly due to permission error.
            $this->errors[] = get_string('langpacknotremoved', 'tool_langimport', $lang);
            return false;
        }
    }
953963
public function isAppReadyToInstall() {
		$checkPHPversion = $this->checkPhpVersion();
		if ($checkPHPversion === false) {
			return false;
		}

		$checkPHPextensions = $this->checkPhpExtensions(true);
		if ($checkPHPextensions === false) {
			return false;
		}

		return true;
	}
1184157
public function uninstallFilter()
    {
        if ($this->isMuted()) {
            $this->previousFilter = null;
            return $this;
        }

        $this->filter = null;
        return $this;
    }
121612
public function install()
    {
        $this->assertIsDebugMode();

		$success = false;
		try {
			$extInstaller = new tao_install_ExtensionInstaller($this->getCurrentExtension());
			$extInstaller->install();
			$message =   __('Extension "%s" has been installed', $this->getCurrentExtension()->getId());
			$success = true;

			// reinit user session
			$session = $this->getSession()->refresh();
		}
		catch(common_ext_ExtensionException $e) {
			$message = $e->getMessage();
		}

        $this->returnJson(array('success' => $success, 'message' => $message));
	}
1133059
public function uninstall($options = array ()) {
        $processed = array();
        if (!is_array($options)) {
            $options= array(xPDOTransport::PACKAGE_ACTION => xPDOTransport::ACTION_UNINSTALL);
        } elseif (!isset($options[xPDOTransport::PACKAGE_ACTION])) {
            $options[xPDOTransport::PACKAGE_ACTION]= xPDOTransport::ACTION_UNINSTALL;
        }
        if (!empty ($this->vehicles)) {
            $this->_preserved = $this->loadPreserved();
            $vehicleArray = array_reverse($this->vehicles, true);
            foreach ($vehicleArray as $vIndex => $vehicleMeta) {
                $vOptions = array_merge($options, $vehicleMeta);
                if ($this->xpdo->getDebug() === true) {
                    $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, "Removing Vehicle: " . print_r($vOptions, true));
                }
                if ($vehicle = $this->get($vehicleMeta['filename'], $vOptions)) {
                    $processed[$vehicleMeta['guid']] = $vehicle->uninstall($this, $vOptions);
                } else {
                    $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Could not load vehicle: ' . print_r($vOptions, true));
                }
            }
        } else {
            $this->xpdo->log(xPDO::LOG_LEVEL_WARN, 'No vehicles are defined in the transport package (' . $this->signature . ') for removal');
        }
        $uninstalled = (array_search(false, $processed, true) === false);
        return $uninstalled;
    }
1071926
public void removeExtension() {

		try {
			if (extensionsDao.isTableExists()) {
				extensionsDao.deleteByExtension(EXTENSION_NAME);
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to delete CRS WKT extension. GeoPackage: "
							+ geoPackage.getName(), e);
		}

	}
134786
public function removeAllowedExtension($extension)
    {
        $key = array_search($extension, $this->allowedExtensions);
        if ($key !== false) {
            unset($this->allowedExtensions[$key]);
            return true;
        }

        return false;
    }
108853
public function uninstall(): OperationResult
    {
        $result = new OperationResult();

        foreach (self::ENV_FILES as $file) {
            $file = "{$this->projectRootDir}/{$file}";
            if (file_exists($file)) {
                $envContent = file_get_contents($file);
                assert(is_string($envContent));

                $startString = "\n###BEGIN-Rikudou-Installer-{$this->packageName}###";
                $endString = "###END-Rikudou-Installer-{$this->packageName}###";

                $startPos = strpos($envContent, $startString);
                if ($startPos === false) {
                    continue;
                }
                $endPos = strpos($envContent, $endString, $startPos);
                if ($endPos === false) {
                    continue;
                }
                $endPos += strlen($endString);

                $resultEnv = substr_replace($envContent, '', $startPos, $endPos - $startPos);
                if (file_put_contents($file, $resultEnv, LOCK_EX) === false) {
                    $result->addErrorMessage("Could not uninstall env variables from {$this->packageName}");
                }
            }
        }

        if ($result->isSuccess()) {
            $result->addStatusMessage("Successfully uninstalled env variables from {$this->packageName}");
        }

        return $result;
    }
1199120
public function uninstall($id)
    {
        $extension = $this->getModel()->query()->findOrFail($id);
        // TODO: remove extension files.
        $extension->delete();
    }
870553
protected function deleteExtension()
    {
        $extensionEntity = $this->getExtensionEntity();

        $this->executeAction(ExtensionManager::DELETE, array('id' => $extensionEntity->get('id')));
    }
420697
public function actionInstall()
    {
       
        $extensionId = $this->options['extension']; // ID of the extension to install.
        $importLocalData = $this->options['data']; // Import local data (local.rdf) or not ?
        try{
            // Retrieve the extension's information.
            $this->outVerbose("Locating extension '${extensionId}'...");
            $extensionManager = common_ext_ExtensionsManager::singleton();
            $ext = $extensionManager->getExtensionById($extensionId);
            $this->outVerbose("Extension located.");
            
            try{
                // Install the extension.
                $this->outVerbose("Installing extension '${extensionId}'...");
                $installer = new tao_install_ExtensionInstaller($ext, $importLocalData);
                $installer->install();
                $this->outVerbose("Extension successfully installed.");
            }
            catch (common_ext_ForbiddenActionException $e){
                $this->error("A forbidden action was undertaken: " . $e->getMessage() . " .", true);
            }
            catch (common_ext_AlreadyInstalledException $e){
                $this->error("Extension '" . $e->getExtensionId() . "' is already installed.", true);
            }
            catch (common_ext_MissingExtensionException $e){
                $this->error("Extension '" . $extensionId . " is dependant on extension '" . $e->getExtensionId() . "' but is missing. Install '" . $e->getExtensionId() . "' first.", true);
            }
        }
        catch (common_ext_ExtensionException $e){
            $this->error("An unexpected error occured: " . $e->getMessage(), true);
        }
      
    }
766071
public function delete() : bool
    {
        $removed = null;

        if ($this->isDirectory()) {
            $removed = rmdir($this->realPath);
        } else {
            $removed = unlink($this->realPath);
        }

        return $removed;
    }