Yaffs site version 1.1
[yaffs-website] / web / modules / contrib / advagg / advagg_validator / src / Form / CssLintForm.php
1 <?php
2
3 namespace Drupal\advagg_validator\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6
7 /**
8  * Configure form for CSSHint validation of CSS files.
9  */
10 class CssLintForm extends BaseValidatorForm {
11
12   /**
13    * {@inheritdoc}
14    */
15   public function getFormId() {
16     return 'advagg_validator_csslint';
17   }
18
19   /**
20    * {@inheritdoc}
21    */
22   public function buildForm(array $form, FormStateInterface $form_state) {
23     $form = parent::generateForm('css');
24     if (file_exists(DRUPAL_ROOT . '/.csslintrc')) {
25       $json_string = file_get_contents(DRUPAL_ROOT . '/.csslintrc');
26       if (!empty($json_string)) {
27         $json_data = json_decode($json_string, TRUE);
28       }
29     }
30     $form['#attached']['library'][] = 'advagg_validator/csslint';
31     if (!empty($json_data)) {
32       $form['#attached']['drupalSettings']['csslint'] = [
33         'rules' => $json_data,
34       ];
35     }
36     $form = parent::buildForm($form, $form_state);
37     unset($form['actions']);
38     return $form;
39   }
40
41 }