ConfigTranslationFormBase::submitForm

public ConfigTranslationFormBase::submitForm(array &$form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

core/modules/config_translation/src/Form/ConfigTranslationFormBase.php, line 197

Class

ConfigTranslationFormBase
Provides a base form for configuration translations.

Namespace

Drupal\config_translation\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $form_values = $form_state->getValue(array('translation', 'config_names'));

  foreach ($this->mapper->getConfigNames() as $name) {
    $schema = $this->typedConfigManager->get($name);

    // Set configuration values based on form submission and source values.
    $base_config = $this->configFactory()->getEditable($name);
    $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name);

    $element = $this->createFormElement($schema);
    $element->setConfig($base_config, $config_translation, $form_values[$name]);

    // If no overrides, delete language specific configuration file.
    $saved_config = $config_translation->get();
    if (empty($saved_config)) {
      $config_translation->delete();
    }
    else {
      $config_translation->save();
    }
  }

  $form_state->setRedirect(
  $this->mapper->getOverviewRoute(), 
  $this->mapper->getOverviewRouteParameters()
  );
}
doc_Drupal
2016-10-29 08:54:59
Comments
Leave a Comment

Please login to continue.