Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / language / src / Form / NegotiationSessionForm.php
1 <?php
2
3 namespace Drupal\language\Form;
4
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Configure the session language negotiation method for this site.
10  */
11 class NegotiationSessionForm extends ConfigFormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'language_negotiation_configure_session_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function getEditableConfigNames() {
24     return ['language.negotiation'];
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function buildForm(array $form, FormStateInterface $form_state) {
31     $config = $this->config('language.negotiation');
32     $form['language_negotiation_session_param'] = [
33       '#title' => $this->t('Request/session parameter'),
34       '#type' => 'textfield',
35       '#default_value' => $config->get('session.parameter'),
36       '#description' => $this->t('Name of the request/session parameter used to determine the desired language.'),
37     ];
38
39     $form_state->setRedirect('language.negotiation');
40
41     return parent::buildForm($form, $form_state);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function submitForm(array &$form, FormStateInterface $form_state) {
48     $this->config('language.negotiation')
49       ->set('session.parameter', $form_state->getValue('language_negotiation_session_param'))
50       ->save();
51
52     parent::submitForm($form, $form_state);
53   }
54
55 }