e8d17edd257d3c1e24f523139cbddeef9617ad75
[yaffs-website] / web / core / modules / system / src / Form / ThemeAdminForm.php
1 <?php
2
3 namespace Drupal\system\Form;
4
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Form to select the administration theme.
10  */
11 class ThemeAdminForm extends ConfigFormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'system_themes_admin_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function getEditableConfigNames() {
24     return ['system.theme'];
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
31     // Administration theme settings.
32     $form['admin_theme'] = [
33       '#type' => 'details',
34       '#title' => $this->t('Administration theme'),
35       '#open' => TRUE,
36     ];
37     $form['admin_theme']['admin_theme'] = [
38       '#type' => 'select',
39       '#options' => [0 => $this->t('Default theme')] + $theme_options,
40       '#title' => $this->t('Administration theme'),
41       '#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
42       '#default_value' => $this->config('system.theme')->get('admin'),
43     ];
44     $form['admin_theme']['actions'] = ['#type' => 'actions'];
45     $form['admin_theme']['actions']['submit'] = [
46       '#type' => 'submit',
47       '#value' => $this->t('Save configuration'),
48       '#button_type' => 'primary',
49     ];
50     return $form;
51   }
52
53   /**
54    * {@inheritdoc}
55    */
56   public function submitForm(array &$form, FormStateInterface $form_state) {
57     parent::submitForm($form, $form_state);
58     $this->config('system.theme')->set('admin', $form_state->getValue('admin_theme'))->save();
59   }
60
61 }