Back to LibraryAdapter class

Method finaliseInstall

protected void
finaliseInstall
()
Method to finalise the installation processing
Returns
  • void
Since
  • 3.4
-
  • \RuntimeException

Method finaliseInstall - Source code

/**
 * Method to finalise the installation processing
 *
 * @return  void
 *
 * @since   3.4
 * @throws  \RuntimeException
 */
protected function finaliseInstall()
{
    // Clobber any possible pending updates
    /** @var Update $update */
    $update = Table::getInstance('update');
    $uid = $update->find(array('element' => $this->element, 'type' => $this->type));
    if ($uid) {
        $update->delete($uid);
    }
    // Lastly, we will copy the manifest file to its appropriate place.
    if ($this->route !== 'discover_install') {
        $manifest = array();
        $manifest['src'] = $this->parent->getPath('manifest');
        $manifest['dest'] = JPATH_MANIFESTS . '/libraries/' . $this->element . '.xml';
        $destFolder = \dirname($manifest['dest']);
        if (!is_dir($destFolder) && !@mkdir($destFolder)) {
            // Install failed, rollback changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COPY_SETUP', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
        if (!$this->parent->copyFiles(array($manifest), true)) {
            // Install failed, rollback changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COPY_SETUP', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
        // If there is a manifest script, let's copy it.
        if ($this->manifest_script) {
            $path['src'] = $this->parent->getPath('source') . '/' . $this->manifest_script;
            $path['dest'] = $this->parent->getPath('extension_root') . '/' . $this->manifest_script;
            if ($this->parent->isOverwrite() || !file_exists($path['dest'])) {
                if (!$this->parent->copyFiles(array($path))) {
                    // Install failed, rollback changes
                    throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_MANIFEST', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
                }
            }
        }
    }
}