Same filename in other branches
  1. 5.0.x advagg_validator/src/Form/CssLintForm.php
  2. 6.0.x advagg_validator/src/Form/CssLintForm.php
  3. 8.x-3.x advagg_validator/src/Form/CssLintForm.php
  4. 8.x-4.x advagg_validator/src/Form/CssLintForm.php

Namespace

Drupal\advagg_validator\Form

File

advagg_validator/src/Form/CssLintForm.php

View source
<?php

namespace Drupal\advagg_validator\Form;

use Drupal\Core\Form\FormStateInterface;

/**
 * Configure form for CSSHint validation of CSS files.
 */
class CssLintForm extends BaseValidatorForm {
    
    /**
     * {@inheritdoc}
     */
    public function getFormId() {
        return 'advagg_validator_csslint';
    }
    
    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state) {
        $form = parent::generateForm('css');
        if (file_exists(DRUPAL_ROOT . '/.csslintrc')) {
            $json_string = file_get_contents(DRUPAL_ROOT . '/.csslintrc');
            if (!empty($json_string)) {
                $json_data = json_decode($json_string, TRUE);
            }
        }
        $form['#attached']['library'][] = 'advagg_validator/csslint';
        if (!empty($json_data)) {
            $form['#attached']['drupalSettings']['csslint'] = [
                'rules' => $json_data,
            ];
        }
        $form = parent::buildForm($form, $form_state);
        unset($form['actions']);
        return $form;
    }

}

Classes

Title Deprecated Summary
CssLintForm Configure form for CSSHint validation of CSS files.