Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / slick / slick_ui / src / Form / SlickSettingsForm.php
1 <?php
2
3 namespace Drupal\slick_ui\Form;
4
5 use Drupal\Core\Form\ConfigFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Defines the Slick admin settings form.
10  */
11 class SlickSettingsForm extends ConfigFormBase {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function getFormId() {
17     return 'slick_settings_form';
18   }
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function getEditableConfigNames() {
24     return ['slick.settings'];
25   }
26
27   /**
28    * Implements \Drupal\Core\Form\FormInterface::buildForm().
29    */
30   public function buildForm(array $form, FormStateInterface $form_state) {
31     $config = $this->config('slick.settings');
32
33     $form['module_css'] = [
34       '#type'          => 'checkbox',
35       '#title'         => $this->t('Enable Slick module slick.theme.css'),
36       '#description'   => $this->t('Uncheck to permanently disable the module slick.theme.css, normally included along with skins.'),
37       '#default_value' => $config->get('module_css'),
38       '#prefix'        => $this->t("Note! Slick doesn't need Slick UI to run. It is always safe to uninstall Slick UI once done with optionsets."),
39     ];
40
41     $form['slick_css'] = [
42       '#type'          => 'checkbox',
43       '#title'         => $this->t('Enable Slick library slick-theme.css'),
44       '#description'   => $this->t('Uncheck to permanently disable the optional slick-theme.css, normally included along with skins.'),
45       '#default_value' => $config->get('slick_css'),
46     ];
47
48     return parent::buildForm($form, $form_state);
49   }
50
51   /**
52    * Implements \Drupal\Core\Form\FormInterface::submitForm().
53    */
54   public function submitForm(array &$form, FormStateInterface $form_state) {
55
56     $this->configFactory->getEditable('slick.settings')
57       ->set('slick_css', $form_state->getValue('slick_css'))
58       ->set('module_css', $form_state->getValue('module_css'))
59       ->save();
60
61     // Invalidate the library discovery cache to update new assets.
62     \Drupal::service('library.discovery')->clearCachedDefinitions();
63
64     parent::submitForm($form, $form_state);
65   }
66
67 }