You are here

public function ConfigTranslationDeleteForm::submitForm in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php \Drupal\config_translation\Form\ConfigTranslationDeleteForm::submitForm()

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/ConfigTranslationDeleteForm.php, line 134

Class

ConfigTranslationDeleteForm
Builds a form to delete configuration translation.

Namespace

Drupal\config_translation\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  foreach ($this->mapper
    ->getConfigNames() as $name) {
    $this->languageManager
      ->getLanguageConfigOverride($this->language
      ->getId(), $name)
      ->delete();
  }

  // Flush all persistent caches.
  $this->moduleHandler
    ->invokeAll('cache_flush');
  foreach (Cache::getBins() as $cache_backend) {
    $cache_backend
      ->deleteAll();
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('@language translation of %label was deleted', [
    '%label' => $this->mapper
      ->getTitle(),
    '@language' => $this->language
      ->getName(),
  ]));
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}