You are here

protected function BaseValidatorForm::hideGoodFiles in Advanced CSS/JS Aggregation 8.2

Same name and namespace in other branches
  1. 8.4 advagg_validator/src/Form/BaseValidatorForm.php \Drupal\advagg_validator\Form\BaseValidatorForm::hideGoodFiles()
  2. 8.3 advagg_validator/src/Form/BaseValidatorForm.php \Drupal\advagg_validator\Form\BaseValidatorForm::hideGoodFiles()

Do not display info on a file if it is valid.

Parameters

array $info: Array containing info about validators and if the file is valid.

Return value

array $info array minus data if that file is valid.

2 calls to BaseValidatorForm::hideGoodFiles()
CssW3Form::submitCheckAll in advagg_validator/src/Form/CssW3Form.php
CssW3Form::submitCheckDirectory in advagg_validator/src/Form/CssW3Form.php

File

advagg_validator/src/Form/BaseValidatorForm.php, line 158

Class

BaseValidatorForm
Base form for all advagg validator options.

Namespace

Drupal\advagg_validator\Form

Code

protected function hideGoodFiles(array $info) {
  $output = [];
  foreach ($info as $filename => $validators) {
    foreach ($validators as $v_name => $v_data) {
      $output[$filename][$v_name] = [
        '#prefix' => '<em>' . $filename . ':</em> ',
      ];
      if (!empty($v_data['validity'])) {
        $output[$filename][$v_name]['#markup'] = t('valid');
      }
      elseif (isset($v_data['error'])) {
        $output[$filename][$v_name]['error'] = $v_data['error'];
      }
      else {
        $output[$filename][$v_name]['options'] = [
          '#markup' => '<em>' . t('Options:') . '</em><br/>',
        ];
        foreach ($v_data['options'] as $option => $value) {
          $output[$filename][$v_name]['options'][] = [
            '#markup' => new HtmlEscapedText($option) . ': ' . new HtmlEscapedText($value),
            '#suffix' => '</br>',
          ];
        }
        if (isset($v_data['errors'])) {
          $output[$filename][$v_name]['errors'] = [
            '#markup' => '<em>' . t('Errors:') . '</em>',
          ];
          foreach ($v_data['errors'] as $error) {
            $output[$filename][$v_name]['errors'][] = [
              '#prefix' => '<pre>',
              '#plain_text' => print_r($error, TRUE),
              '#suffix' => '</pre>',
            ];
          }
        }
        if (isset($v_data['warnings'])) {
          $output[$filename][$v_name]['warnings'] = [
            '#markup' => '<em>' . t('Warnings:') . '</em>',
          ];
          foreach ($v_data['warnings'] as $warning) {
            $output[$filename][$v_name]['warnings'][] = [
              '#prefix' => '<pre>',
              '#plain_text' => print_r($warning, TRUE),
              '#suffix' => '</pre>',
            ];
          }
        }
      }
    }
  }
  return $output;
}