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 5, 2020
1 parent 3668584 commit 9e0ff28
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
16 changes: 0 additions & 16 deletions oe_multilingual.module
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ function oe_multilingual_preprocess_language_selection_page_content(&$variables)
}
}

/**
* Implements hook_ENTITY_TYPE_presave() for the configurable language entities.
*
* Make sure whenever we add or re-add a language it follows the configuration
* set by the module's configuration files.
*/
function oe_multilingual_configurable_language_presave(EntityInterface $entity) {
$storage = new FileStorage(drupal_get_path('module', 'oe_multilingual') . '/config/install');
$values = $storage->read('language.entity.' . $entity->id());
if ($values) {
foreach ($values as $key => $value) {
$entity->set($key, $value);
}
}
}

/**
* Implements hook_ENTITY_TYPE_insert() 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 9e0ff28

Please sign in to comment.