/**
* Method to do any prechecks and setup the uninstall job
*
* @return void
*
* @since 4.0.0
*/
protected function setupUninstall()
{
$manifestFile = JPATH_MANIFESTS . '/files/' . $this->extension->element . '.xml';
// Because libraries may not have their own folders we cannot use the standard method of finding an installation manifest
if (!file_exists($manifestFile)) {
// Remove this row entry since its invalid
$this->extension->delete($this->extension->extension_id);
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_NOTFOUND_MANIFEST'));
}
// Set the files root path
$this->parent->setPath('extension_root', JPATH_MANIFESTS . '/files/' . $this->extension->element);
// Set the source path for compatibility with the API
$this->parent->setPath('source', $this->parent->getPath('extension_root'));
$xml = simplexml_load_file($manifestFile);
// If we cannot load the XML file return null
if (!$xml) {
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_LOAD_MANIFEST'));
}
// Check for a valid XML root tag.
if ($xml->getName() !== 'extension') {
throw new \RuntimeException(Text::_('JLIB_INSTALLER_ERROR_FILE_UNINSTALL_INVALID_MANIFEST'));
}
$this->setManifest($xml);
// Attempt to load the language file; might have uninstall strings
$this->loadLanguage(JPATH_MANIFESTS . '/files');
}