/**
* Method to do any prechecks and setup the uninstall job
*
* @return void
*
* @since 4.0.0
*/
protected function setupUninstall()
{
// Grab a copy of the client details
$client = ApplicationHelper::getClientInfo($this->extension->client_id);
// Check the element isn't blank to prevent nuking the languages directory...just in case
if (empty($this->extension->element)) {
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_ELEMENT_EMPTY'));
}
// Verify that it's not the default language for that client
$params = ComponentHelper::getParams('com_languages');
if ($params->get($client->name) === $this->extension->element) {
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_DEFAULT'));
}
// Construct the path from the client, the language and the extension element name
$path = $client->path . '/language/' . $this->extension->element;
// Get the package manifest object and remove media
$this->parent->setPath('source', $path);
// Check it exists
if (!Folder::exists($path)) {
// If the folder doesn't exist lets just nuke the row as well and presume the user killed it for us
$this->extension->delete();
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_LANG_UNINSTALL_PATH_EMPTY'));
}
// We do findManifest to avoid problem when uninstalling a list of extension: getManifest cache its manifest file
$this->parent->findManifest();
$this->setManifest($this->parent->getManifest());
}