You are here

public function Drupal7Backend::language_removeFromDatabase in Configuration Management 7.3

Overrides BackendInterface::language_removeFromDatabase

File

src/Backends/Drupal7Backend.php, line 143

Class

Drupal7Backend

Namespace

Configuration\Backends

Code

public function language_removeFromDatabase($langcode) {
  $languages = language_list();
  if (isset($languages[$langcode])) {

    // Remove translations first.
    db_delete('locales_target')
      ->condition('language', $langcode)
      ->execute();
    cache_clear_all('locale:' . $langcode, 'cache');

    // With no translations, this removes existing JavaScript translations file.
    _locale_rebuild_js($langcode);

    // Remove the language.
    db_delete('languages')
      ->condition('language', $langcode)
      ->execute();
    db_update('node')
      ->fields(array(
      'language' => '',
    ))
      ->condition('language', $langcode)
      ->execute();
    if ($languages[$langcode]->enabled) {
      variable_set('language_count', variable_get('language_count', 1) - 1);
    }
    module_invoke_all('multilingual_settings_changed');
  }

  // Changing the language settings impacts the interface:
  cache_clear_all('*', 'cache_page', TRUE);
}