You are here

public static function QuailApiSettings::get_standards in Quail API 8

Returns an array of standards that are supported.

Parameters

string|null $standard: (optional) Providing a valid standard name will cause the return value to only contain the standard that matches this string.

string $target: (optional) Target allows for selecting standards based on some category or purpose. The target, in general, represents the scope in which the standards will be applied. The following targets are directly supported: 'snippet', 'page'.

Return value

array An array of standards that are supported by this module or extending modules. The array keys are the machine names for each standard.

1 call to QuailApiSettings::get_standards()
QuailApiSettings::get_standards_list in src/QuailApiSettings.php
Returns a list of standards.

File

src/QuailApiSettings.php, line 28

Class

QuailApiSettings
Class QuailApiSettings.

Namespace

Drupal\quail_api

Code

public static function get_standards($standard = NULL, $target = 'snippet') {
  $standards =& drupal_static('quail_api_' . __FUNCTION__, NULL);
  if (!isset($standards)) {
    if ($cache = \Drupal::cache()
      ->get('quail_api_standards')) {
      $standards = $cache->data;
    }
    else {
      \Drupal::moduleHandler()
        ->alter('quail_api_get_standards', $standard, $other_arguments);
    }
  }
  if (isset($standards)) {
    if (!is_null($standard)) {
      if (isset($standards[$standard])) {
        return $standards[$standard];
      }
      return [];
    }
    return $standards;
  }
  $standards = [];
  if ($target == 'snippet' || $target == 'page') {
    $reporter = 'quail_api';
    $module = 'quail_api';
    $standards['all'] = [
      'human_name' => t("All Tests"),
      'module' => $module,
      'description' => t("Validate using all known tests. This is more efficient than validating against each individual standard because identical tests are not run multiple times."),
      'guideline' => $target == 'snippet' ? 'quail_api_all' : 'all',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['section_508'] = [
      'human_name' => t("Section 508"),
      'module' => $module,
      'description' => t("Validate using the <a href='@section_508'>Section 508</a> standard.", [
        '@section_508' => 'http://www.section508.gov/index.cfm?fuseAction=stdsdoc#Web',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_section508' : 'section508',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_1_0_a'] = [
      'human_name' => t("WCAG 1.0 a"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_1_0'>WCAG 1.0</a> (<a href='@wcag_1_0_a'>A</a>) standard.", [
        '@wcag_1_0' => 'http://www.w3.org/TR/WCAG10/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG1A-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag1a' : 'wcag1a',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_1_0_aa'] = [
      'human_name' => t("WCAG 1.0 aa"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_1_0'>WCAG 1.0</a> (<a href='@wcag_1_0_aa'>AA</a>) standard.", [
        '@wcag_1_0' => 'http://www.w3.org/TR/WCAG10/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG1AA-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag1aa' : 'wcag1aa',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_1_0_aaa'] = [
      'human_name' => t("WCAG 1.0 aaa"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_1_0'>WCAG 1.0</a> (<a href='@wcag_1_0_aaa'>AAA</a>) standard.", [
        '@wcag_1_0' => 'http://www.w3.org/TR/WCAG10/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG1AAA-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag1aaa' : 'wcag1aaa',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_2_0_a'] = [
      'human_name' => t("WCAG 2.0 a"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_2_0'>WCAG 2.0</a> (<a href='@wcag_2_0_a'>A</a>) standard.", [
        '@wcag_2_0' => 'http://www.w3.org/TR/WCAG20/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG2A-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag2a' : 'wcag2a',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_2_0_aa'] = [
      'human_name' => t("WCAG 2.0 aa"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_2_0'>WCAG 2.0</a> (<a href='@wcag_2_0_aa'>AA</a>) standard.", [
        '@wcag_2_0' => 'http://www.w3.org/TR/WCAG20/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG2AA-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag2aa' : 'wcag2aa',
      'reporter' => $reporter,
      'target' => $target,
    ];
    $standards['wcag_2_0_aaa'] = [
      'human_name' => t("WCAG 2.0 aaa"),
      'module' => $module,
      'description' => t("Validate using the <a href='@wcag_2_0'>WCAG 2.0</a> (<a href='@wcag_2_0_aaa'>AAA</a>) standard.", [
        '@wcag_2_0' => 'http://www.w3.org/TR/WCAG20/',
        '@wcag_1_0_a' => 'http://www.w3.org/WAI/WCAG2AAA-Conformance',
      ]),
      'guideline' => $target == 'snippet' ? 'quail_api_wcag2aaa' : 'wcag2aaa',
      'reporter' => $reporter,
      'target' => $target,
    ];
  }
  $other_arguments = [];
  $other_arguments['target'] = $target;
  \Drupal::cache()
    ->set('quail_api_standards', $standards);
  if (!is_null($standard)) {
    if (isset($standards[$standard])) {
      return $standards[$standard];
    }
    return [];
  }
  return $standards;
}