You are here

search_api_solr_multilingual.install in Search API Multilingual Solr Search 8.3

Same filename and directory in other branches
  1. 8 search_api_solr_multilingual.install

File

search_api_solr_multilingual.install
View source
<?php

function search_api_solr_multilingual_update_dependencies() {

  // Ensure that all pending updates of search_api_solr_multilingual are done
  // before starting the upgrade to search_api_solr 2.x and 3.x.
  $dependencies['search_api_solr'][8201] = [
    'search_api_solr_multilingual' => 8300,
  ];

  // Avoid 'The "solr_field_type" entity type does not exist.'
  $dependencies['search_api_solr_multilingual'][8300] = [
    'search_api_solr' => 8200,
  ];
  return $dependencies;
}

/**
 * @throws \Exception
 */
function search_api_solr_multilingual_install() {

  /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
  $module_installer = \Drupal::service('module_installer');
  $module_installer
    ->uninstall([
    'search_api_solr_multilingual',
  ]);
  throw new \Exception('search_api_solr_multilingual must not be installed again! It became part of search_api_solr itself!');
}

/**
 * Gets all backend configs for active Solr multilingual servers.
 *
 * @return array
 *   All backend configs for active Solr multilingual servers keyed by server
 *   name.
 */
function search_api_solr_multilingual_update_helper_get_backend_configs() {
  module_load_install('search_api_solr');
  return search_api_solr_update_helper_get_backend_configs('search_api_solr_multilingual');
}

/**
 * Saves a modified backend config for a given Solr server.
 *
 * @param string $server_name
 * @param array $backend_config
 * @param bool $trusted_data
 */
function search_api_solr_multilingual_update_helper_save_backend_config($server_name, array $backend_config, $trusted_data = TRUE) {
  module_load_install('search_api_solr');
  search_api_solr_update_helper_save_backend_config($server_name, $backend_config, $trusted_data);
}

/**
 * Fixes erroneous left overs from managed field types in unmanaged field types.
 */
function search_api_solr_multilingual_update_8001() {
}

/**
 * Migrate langcode to field_type_language_code.
 */
function search_api_solr_multilingual_update_8002() {
  foreach (search_api_solr_multilingual_update_helper_get_backend_configs() as $server_name => $backend_config) {
    $backend_config['field_type_language_code'] = $backend_config['langcode'];
    $backend_config['langcode'] = 'en';
    search_api_solr_multilingual_update_helper_save_backend_config($server_name, $backend_config);
  }
}

/**
 * Add default domain settings to existing solr field types and backends.
 */
function search_api_solr_multilingual_update_8003() {
  foreach (search_api_solr_multilingual_update_helper_get_backend_configs() as $server_name => $backend_config) {
    $backend_config['sasm_domain'] = 'generic';
    search_api_solr_multilingual_update_helper_save_backend_config($server_name, $backend_config);
  }
}

/**
 * Add search page independent language setting to existing solr backends.
 */
function search_api_solr_multilingual_update_8004() {
  foreach (search_api_solr_multilingual_update_helper_get_backend_configs() as $server_name => $backend_config) {
    $backend_config['sasm_search_page_include_language_independent'] = FALSE;
    search_api_solr_multilingual_update_helper_save_backend_config($server_name, $backend_config);
  }
}

/**
 * Deletes potential left over configs from multilingual.
 */
function search_api_solr_multilingual_update_8300() {
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('search_api_solr_multilingual') as $config_name) {
    $config_factory
      ->getEditable($config_name)
      ->delete();
  }
}

Functions

Namesort descending Description
search_api_solr_multilingual_install
search_api_solr_multilingual_update_8001 Fixes erroneous left overs from managed field types in unmanaged field types.
search_api_solr_multilingual_update_8002 Migrate langcode to field_type_language_code.
search_api_solr_multilingual_update_8003 Add default domain settings to existing solr field types and backends.
search_api_solr_multilingual_update_8004 Add search page independent language setting to existing solr backends.
search_api_solr_multilingual_update_8300 Deletes potential left over configs from multilingual.
search_api_solr_multilingual_update_dependencies
search_api_solr_multilingual_update_helper_get_backend_configs Gets all backend configs for active Solr multilingual servers.
search_api_solr_multilingual_update_helper_save_backend_config Saves a modified backend config for a given Solr server.