function DevelopmentSettingsForm::submitForm

Same name in other branches
  1. 11.x core/modules/system/src/Form/DevelopmentSettingsForm.php \Drupal\system\Form\DevelopmentSettingsForm::submitForm()

Overrides FormInterface::submitForm

File

core/modules/system/src/Form/DevelopmentSettingsForm.php, line 122

Class

DevelopmentSettingsForm
Configure development settings for this site.

Namespace

Drupal\system\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $development_settings = $this->keyValueFactory
        ->get('development_settings');
    $disable_rendered_output_cache_bins_previous = $development_settings->get('disable_rendered_output_cache_bins', FALSE);
    $disable_rendered_output_cache_bins = (bool) $form_state->getValue('disable_rendered_output_cache_bins');
    if ($disable_rendered_output_cache_bins) {
        $development_settings->set('disable_rendered_output_cache_bins', TRUE);
    }
    else {
        $development_settings->delete('disable_rendered_output_cache_bins');
    }
    $twig_development_mode = (bool) $form_state->getValue('twig_development_mode');
    $twig_development_previous = $development_settings->getMultiple([
        'twig_debug',
        'twig_cache_disable',
    ]);
    $twig_development = [
        'twig_debug' => (bool) $form_state->getValue('twig_debug'),
        'twig_cache_disable' => (bool) $form_state->getValue('twig_cache_disable'),
    ];
    if ($twig_development_mode) {
        $invalidate_container = $twig_development_previous !== $twig_development;
        $development_settings->setMultiple($twig_development);
    }
    else {
        $invalidate_container = TRUE;
        $development_settings->deleteMultiple(array_keys($twig_development));
    }
    if ($invalidate_container || $disable_rendered_output_cache_bins_previous !== $disable_rendered_output_cache_bins) {
        $this->kernel
            ->invalidateContainer();
    }
    $this->messenger()
        ->addStatus($this->t('The settings have been saved.'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.