Back to ComponentAdapter 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()
{
    /** @var Update $update */
    $update = Table::getInstance('update');
    // Clobber any possible pending updates
    $uid = $update->find(array('element' => $this->element, 'type' => $this->extension->type, 'client_id' => 1));
    if ($uid) {
        $update->delete($uid);
    }
    // We will copy the manifest file to its appropriate place.
    if ($this->route !== 'discover_install') {
        if (!$this->parent->copyManifest()) {
            // Install failed, roll back changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_COPY_SETUP', Text::_('JLIB_INSTALLER_' . strtoupper($this->route))));
        }
    }
    // Time to build the admin menus
    if (!$this->_buildAdminMenus($this->extension->extension_id)) {
        Log::add(Text::_('JLIB_INSTALLER_ABORT_COMP_BUILDADMINMENUS_FAILED'), Log::WARNING, 'jerror');
    }
    // Make sure that menu items pointing to the component have correct component id assigned to them.
    // Prevents message "Component 'com_extension' does not exist." after uninstalling / re-installing component.
    if (!$this->_updateMenus($this->extension->extension_id)) {
        Log::add(Text::_('JLIB_INSTALLER_ABORT_COMP_UPDATESITEMENUS_FAILED'), Log::WARNING, 'jerror');
    }
    /** @var Asset $asset */
    $asset = Table::getInstance('Asset');
    // Check if an asset already exists for this extension and create it if not
    if (!$asset->loadByName($this->extension->element)) {
        // Register the component container just under root in the assets table.
        $asset->name = $this->extension->element;
        $asset->parent_id = 1;
        $asset->rules = '{}';
        $asset->title = $this->extension->name;
        $asset->setLocation(1, 'last-child');
        if (!$asset->store()) {
            // Install failed, roll back changes
            throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_ROLLBACK', Text::_('JLIB_INSTALLER_' . strtoupper($this->route)), $this->extension->getError()));
        }
    }
}