/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); // Save the default language if changed. $new_id = $form_state->getValue('site_default_language'); if ($new_id != $this->languageManager->getDefaultLanguage()->getId()) { $this->configFactory->getEditable('system.site')->set('default_langcode', $new_id)->save(); $this->languageManager->reset(); } if ($this->languageManager instanceof ConfigurableLanguageManagerInterface) { $this->languageManager->updateLockedLanguageWeights(); } drupal_set_message(t('Configuration saved.')); // Force the redirection to the page with the language we have just // selected as default. $form_state->setRedirectUrl($this->entities[$new_id]->urlInfo('collection', array('language' => $this->entities[$new_id]))); }