Same name in other branches
  1. 5.0.x advagg_validator/src/Form/CssLintForm.php \Drupal\advagg_validator\Form\CssLintForm::decodeRules()
  2. 8.x-3.x advagg_validator/src/Form/CssLintForm.php \Drupal\advagg_validator\Form\CssLintForm::decodeRules()
  3. 8.x-4.x advagg_validator/src/Form/CssLintForm.php \Drupal\advagg_validator\Form\CssLintForm::decodeRules()

Decode a .csslintrc file to rules array.

Paramètres

string $rule_string: The raw rule string.

Return value

array The rules array.

1 call to CssLintForm::decodeRules()
CssLintForm::buildForm dans advagg_validator/src/Form/CssLintForm.php

Fichier

advagg_validator/src/Form/CssLintForm.php, line 54

Classe

CssLintForm
Configure form for CSSHint validation of CSS files.

Namespace

Drupal\advagg_validator\Form

Code

protected function decodeRules($rule_string) {
    $values = [
        'errors' => 2,
        'warning' => 1,
        'ignore' => 0,
        'exclude-list' => 1,
    ];
    $rules = [];
    $group = '';
    $raw = explode("\n", $rule_string);
    foreach ($raw as $rule) {
        if (empty($rule)) {
            continue;
        }
        if (substr($rule, 0, 1) === '-') {
            $split = explode('=', trim($rule, " \t\n\r\x00\v-,"));
            $group = $split[0];
            $rules[$group] = [];
            if (isset($split[1])) {
                $rules[$group][$split[1]] = $values[$group];
            }
            continue;
        }
        $rules[$group][trim($rule, " \t\n\r\x00\v,")] = $values[$group];
    }
    return $rules;
}