summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2017-03-06 18:04:45 (GMT)
committerAlex Pott2017-03-06 18:04:45 (GMT)
commit4229a76be56963e7b5ece053275cfcfcb6cd2a19 (patch)
tree22e5f00e5705b4c7dae7bdf50c25b7f0ecfa0aa2
parent37500c9ab0644b82e4fd8ae0c0d5314bddbba4ab (diff)
Issue #2575535 by bighappyface, heykarthikwithu, rodrigoaguilera, prasad_gogate: Custom language settings configuration is not saved when you have a language selector enabled for any content
-rw-r--r--core/modules/content_translation/src/Tests/ContentTranslationDisableSettingTest.php69
-rw-r--r--core/modules/language/src/Form/ContentLanguageSettingsForm.php4
2 files changed, 73 insertions, 0 deletions
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationDisableSettingTest.php b/core/modules/content_translation/src/Tests/ContentTranslationDisableSettingTest.php
new file mode 100644
index 0000000..a274ad2
--- /dev/null
+++ b/core/modules/content_translation/src/Tests/ContentTranslationDisableSettingTest.php
@@ -0,0 +1,69 @@
+<?php
+
+namespace Drupal\content_translation\Tests;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Test disabling content translation module.
+ *
+ * @group content_translation
+ */
+class ContentTranslationDisableSettingTest extends BrowserTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'content_translation',
+ 'menu_link_content',
+ 'language',
+ ];
+
+ /**
+ * Tests that entity schemas are up-to-date after enabling translation.
+ */
+ public function testDisableSetting() {
+ // Define selectors.
+ $group_checkbox = 'entity_types[menu_link_content]';
+ $translatable_checkbox = 'settings[menu_link_content][menu_link_content][translatable]';
+ $language_alterable = 'settings[menu_link_content][menu_link_content][settings][language][language_alterable]';
+
+ $user = $this->drupalCreateUser([
+ 'administer site configuration',
+ 'administer content translation',
+ 'create content translations',
+ 'administer languages',
+ ]);
+ $this->drupalLogin($user);
+
+ $assert = $this->assertSession();
+
+ $this->drupalGet('admin/config/regional/content-language');
+
+ $assert->checkboxNotChecked('entity_types[menu_link_content]');
+
+ $edit = [
+ $group_checkbox => TRUE,
+ $translatable_checkbox => TRUE,
+ $language_alterable => TRUE,
+ ];
+ $this->submitForm($edit, t('Save configuration'));
+
+ $assert->pageTextContains(t('Settings successfully updated.'));
+
+ $assert->checkboxChecked($group_checkbox);
+
+ $edit = [
+ $group_checkbox => FALSE,
+ $translatable_checkbox => TRUE,
+ $language_alterable => TRUE,
+ ];
+ $this->submitForm($edit, t('Save configuration'));
+
+ $assert->pageTextContains(t('Settings successfully updated.'));
+
+ $assert->checkboxNotChecked($group_checkbox);
+ }
+
+}
diff --git a/core/modules/language/src/Form/ContentLanguageSettingsForm.php b/core/modules/language/src/Form/ContentLanguageSettingsForm.php
index a115529..38aaffa 100644
--- a/core/modules/language/src/Form/ContentLanguageSettingsForm.php
+++ b/core/modules/language/src/Form/ContentLanguageSettingsForm.php
@@ -143,9 +143,13 @@ class ContentLanguageSettingsForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
+ $entity_types = $form_state->getValue('entity_types');
foreach ($form_state->getValue('settings') as $entity_type => $entity_settings) {
foreach ($entity_settings as $bundle => $bundle_settings) {
$config = ContentLanguageSettings::loadByEntityTypeBundle($entity_type, $bundle);
+ if (empty($entity_types[$entity_type])) {
+ $bundle_settings['settings']['language']['language_alterable'] = FALSE;
+ }
$config->setDefaultLangcode($bundle_settings['settings']['language']['langcode'])
->setLanguageAlterable($bundle_settings['settings']['language']['language_alterable'])
->save();