Back to Installer class

Method discover_install

public bool
discover_install
(mixed $eid = null)
Discovered package installation method
Parameters
  • int $eid Extension ID
Returns
  • bool True if successful
Since
  • 3.1
Class: Installer
Project: Joomla

Method discover_install - Source code

/**
 * Discovered package installation method
 *
 * @param   integer  $eid  Extension ID
 *
 * @return  boolean  True if successful
 *
 * @since   3.1
 */
public function discover_install($eid = null)
{
    if (!$eid) {
        $this->abort(Text::_('JLIB_INSTALLER_ABORT_EXTENSIONNOTVALID'));
        return false;
    }
    if (!$this->extension->load($eid)) {
        $this->abort(Text::_('JLIB_INSTALLER_ABORT_LOAD_DETAILS'));
        return false;
    }
    if ($this->extension->state != -1) {
        $this->abort(Text::_('JLIB_INSTALLER_ABORT_ALREADYINSTALLED'));
        return false;
    }
    // Load the adapter(s) for the install manifest
    $type = $this->extension->type;
    $params = array('extension' => $this->extension, 'route' => 'discover_install');
    $adapter = $this->loadAdapter($type, $params);
    if (!\is_object($adapter)) {
        return false;
    }
    if (!method_exists($adapter, 'discover_install') || !$adapter->getDiscoverInstallSupported()) {
        $this->abort(Text::sprintf('JLIB_INSTALLER_ERROR_DISCOVER_INSTALL_UNSUPPORTED', $type));
        return false;
    }
    // The adapter needs to prepare itself
    if (method_exists($adapter, 'prepareDiscoverInstall')) {
        try {
            $adapter->prepareDiscoverInstall();
        } catch (\RuntimeException $e) {
            $this->abort($e->getMessage());
            return false;
        }
    }
    // Add the languages from the package itself
    if (method_exists($adapter, 'loadLanguage')) {
        $adapter->loadLanguage();
    }
    // Fire the onExtensionBeforeInstall event.
    PluginHelper::importPlugin('extension');
    Factory::getApplication()->triggerEvent('onExtensionBeforeInstall', array('method' => 'discover_install', 'type' => $this->extension->get('type'), 'manifest' => null, 'extension' => $this->extension->get('extension_id')));
    // Run the install
    $result = $adapter->discover_install();
    // Fire the onExtensionAfterInstall
    Factory::getApplication()->triggerEvent('onExtensionAfterInstall', array('installer' => clone $this, 'eid' => $result));
    if ($result !== false) {
        // Refresh versionable assets cache
        Factory::getApplication()->flushAssets();
        return true;
    }
    return false;
}