Back to LibraryAdapter class

Method checkExtensionInFilesystem

protected void
checkExtensionInFilesystem
()
Method to check if the extension is present in the filesystem, flags the route as update if so
Returns
  • void
Since
  • 3.4
-
  • \RuntimeException

Method checkExtensionInFilesystem - Source code

/**
 * Method to check if the extension is present in the filesystem, flags the route as update if so
 *
 * @return  void
 *
 * @since   3.4
 * @throws  \RuntimeException
 */
protected function checkExtensionInFilesystem()
{
    if ($this->currentExtensionId) {
        // Already installed, can we upgrade?
        if ($this->parent->isOverwrite() || $this->parent->isUpgrade()) {
            // We can upgrade, so uninstall the old one
            // We don't want to compromise this instance!
            $installer = new Installer();
            $installer->setPackageUninstall(true);
            $installer->uninstall('library', $this->currentExtensionId);
            // Clear the cached data
            $this->currentExtensionId = null;
            $this->extension = Table::getInstance('Extension', 'JTable', array('dbo' => $this->db));
            // From this point we'll consider this an update
            $this->setRoute('update');
        } else {
            // Abort the install, no upgrade possible
            throw new \RuntimeException(Text::_('JLIB_INSTALLER_ABORT_LIB_INSTALL_ALREADY_INSTALLED'));
        }
    }
}