Updated to Drupal 8.5. Core Media not yet in use.
[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  * @internal
12  */
13 class ThemeAdminForm extends ConfigFormBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public function getFormId() {
19     return 'system_themes_admin_form';
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function getEditableConfigNames() {
26     return ['system.theme'];
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function buildForm(array $form, FormStateInterface $form_state, array $theme_options = NULL) {
33     // Administration theme settings.
34     $form['admin_theme'] = [
35       '#type' => 'details',
36       '#title' => $this->t('Administration theme'),
37       '#open' => TRUE,
38     ];
39     $form['admin_theme']['admin_theme'] = [
40       '#type' => 'select',
41       '#options' => [0 => $this->t('Default theme')] + $theme_options,
42       '#title' => $this->t('Administration theme'),
43       '#description' => $this->t('Choose "Default theme" to always use the same theme as the rest of the site.'),
44       '#default_value' => $this->config('system.theme')->get('admin'),
45     ];
46     $form['admin_theme']['actions'] = ['#type' => 'actions'];
47     $form['admin_theme']['actions']['submit'] = [
48       '#type' => 'submit',
49       '#value' => $this->t('Save configuration'),
50       '#button_type' => 'primary',
51     ];
52     return $form;
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   public function submitForm(array &$form, FormStateInterface $form_state) {
59     parent::submitForm($form, $form_state);
60     $this->config('system.theme')->set('admin', $form_state->getValue('admin_theme'))->save();
61   }
62
63 }