/**
* Generic update method for extensions
*
* @param integer $id The extension ID
*
* @return boolean True on success
*
* @since 4.0.0
*/
public function uninstall($id)
{
if (!$this->extension->load((int) $id)) {
Log::add(Text::_('JLIB_INSTALLER_ERROR_UNKNOWN_EXTENSION'), Log::WARNING, 'jerror');
return false;
}
// Joomla 4: Locked extensions cannot be removed.
if (isset($this->extension->locked) && $this->extension->locked) {
Log::add(Text::_('JLIB_INSTALLER_ERROR_UNINSTALL_LOCKED_EXTENSION'), Log::WARNING, 'jerror');
return false;
} elseif (!isset($this->extension->locked) && $this->extension->protected) {
Log::add(Text::_('JLIB_INSTALLER_ERROR_UNINSTALL_PROTECTED_EXTENSION'), Log::WARNING, 'jerror');
return false;
}
/*
* Does this extension have a parent package?
* If so, check if the package disallows individual extensions being uninstalled if the package is not being uninstalled
*/
if ($this->extension->package_id && !$this->parent->isPackageUninstall() && !$this->canUninstallPackageChild($this->extension->package_id)) {
Log::add(Text::sprintf('JLIB_INSTALLER_ERROR_CANNOT_UNINSTALL_CHILD_OF_PACKAGE', $this->extension->name), Log::WARNING, 'jerror');
return false;
}
// Setup the uninstall job as required
try {
$this->setupUninstall();
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
return false;
}
// Set the extension's name and element
$this->name = $this->getName();
$this->element = $this->getElement();
/*
* ---------------------------------------------------------------------------------------------
* Installer Trigger Loading and Uninstall
* ---------------------------------------------------------------------------------------------
*/
$this->setupScriptfile();
try {
$this->triggerManifestScript('preflight');
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
return false;
}
try {
$this->triggerManifestScript('uninstall');
} catch (\RuntimeException $e) {
// Ignore errors for now
}
// Tasks from here may fail but we will still attempt to finish the uninstall process
$retval = true;
/*
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
try {
$this->parseQueries();
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
$retval = false;
}
/*
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
try {
$this->removeExtensionFiles();
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
$retval = false;
}
/*
* ---------------------------------------------------------------------------------------------
* Finalization and Cleanup Section
* ---------------------------------------------------------------------------------------------
*/
try {
$retval |= $this->finaliseUninstall();
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
$retval = false;
}
// And now we run the postflight
try {
$this->triggerManifestScript('postflight');
} catch (\RuntimeException $e) {
Log::add($e->getMessage(), Log::WARNING, 'jerror');
$retval = false;
}
return $retval;
}