Skip to content

Commit

Permalink
OPENEUROPA-2768: Remove presave that forces language configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagyad committed Feb 4, 2020
1 parent 3668584 commit b18e357
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 45 deletions.
15 changes: 0 additions & 15 deletions oe_multilingual.module
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,6 @@ function oe_multilingual_language_fallback_candidates_alter(array &$candidates,
}
}

/**
* Implements hook_preprocess_language_selection_page_content().
*
* Replaces the language links labels with the native language version.
*/
function oe_multilingual_preprocess_language_selection_page_content(&$variables): void {
/** @var \Drupal\Core\Language\LanguageInterface[] $original_languages */
$original_languages = \Drupal::service('language_manager')->getNativeLanguages();
foreach ($variables['language_links']['#items'] as $langcode => &$item) {
if (isset($original_languages[$langcode])) {
$item['#title'] = $original_languages[$langcode]->getName();
}
}
}

/**
* Implements hook_ENTITY_TYPE_presave() for the configurable language entities.
*
Expand Down
30 changes: 0 additions & 30 deletions tests/Kernel/InstallationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,6 @@ protected function setUp() {
oe_multilingual_install();
}

/**
* Test languages keep the configuration after being deleted and recreated.
*/
public function testLanguageConfiguration(): void {
// Delete a language.
$storage = $this->container->get('entity_type.manager')->getStorage('configurable_language');
/** @var \Drupal\language\Entity\ConfigurableLanguage $old_language */
$old_language = $storage->load('fr');
$old_language->delete();

// Assert the language is deleted.
$language = $storage->load('fr');
$this->assertNull($language);

// Create the same language.
/** @var \Drupal\language\ConfigurableLanguageInterface $new_language */
$new_language = $storage->create(['id' => 'fr']);
$new_language->save();
$new_language = $storage->load('fr');

// Assert the same values apply.
$this->assertEquals($old_language->id(), $new_language->id());
$this->assertEquals($old_language->getWeight(), $new_language->getWeight());
$this->assertEquals($old_language->getName(), $new_language->getName());

// Ensure the correct translation is also present.
$translation = $this->container->get('language_manager')->getLanguageConfigOverride('fr', 'language.entity.fr');
$this->assertEquals('français', $translation->get('label'));
}

/**
* Test proper configuration setup during module installation.
*/
Expand Down

0 comments on commit b18e357

Please sign in to comment.