Back to LanguageAdapter class

Method discover_install

public int
discover_install
()
Custom discover install method Basically updates the manifest cache and leaves everything alone
Returns
  • int The extension id
Since
  • 3.1

Method discover_install - Source code

/**
 * Custom discover install method
 * Basically updates the manifest cache and leaves everything alone
 *
 * @return  integer  The extension id
 *
 * @since   3.1
 */
public function discover_install()
{
    // Need to find to find where the XML file is since we don't store this normally
    $client = ApplicationHelper::getClientInfo($this->parent->extension->client_id);
    $short_element = $this->parent->extension->element;
    $manifestPath = $client->path . '/language/' . $short_element . '/langmetadata.xml';
    if (!is_file($manifestPath)) {
        $manifestPath = $client->path . '/language/' . $short_element . '/' . $short_element . '.xml';
    }
    $this->parent->manifest = $this->parent->isManifest($manifestPath);
    $this->parent->setPath('manifest', $manifestPath);
    $this->parent->setPath('source', $client->path . '/language/' . $short_element);
    $this->parent->setPath('extension_root', $this->parent->getPath('source'));
    $manifest_details = Installer::parseXMLInstallFile($this->parent->getPath('manifest'));
    $this->parent->extension->manifest_cache = json_encode($manifest_details);
    $this->parent->extension->state = 0;
    $this->parent->extension->name = $manifest_details['name'];
    $this->parent->extension->enabled = 1;
    // @todo remove code: $this->parent->extension->params = $this->parent->getParams();
    try {
        $this->parent->extension->check();
        $this->parent->extension->store();
    } catch (\RuntimeException $e) {
        Log::add(Text::_('JLIB_INSTALLER_ERROR_LANG_DISCOVER_STORE_DETAILS'), Log::WARNING, 'jerror');
        return false;
    }
    if ($client->id === 0) {
        $this->createContentLanguage($short_element);
    }
    // Clean installed languages cache.
    Factory::getCache()->clean('com_languages');
    return $this->parent->extension->get('extension_id');
}