You are here

public static function QuailApiSettings::get_severity in Quail API 8

Returns an array of severity levels that are supported.

Parameters

string|null $severity: (optional) A number representing the display level. When defined, the return value to only contain the display level that matches this string. When undefined, all display levels will be loaded into the severitys array.

Return value

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

3 calls to QuailApiSettings::get_severity()
QuailApiSettings::get_default_severity in src/QuailApiSettings.php
Returns an array of quail test display levels, each initialized to TRUE.
QuailApiSettings::get_severity_list in src/QuailApiSettings.php
Returns a list of display levels that are supported.
template_preprocess_quail_api_results in ./quail_api.module
Template preprocess function for quail_api_results.tpl.php.

File

src/QuailApiSettings.php, line 230

Class

QuailApiSettings
Class QuailApiSettings.

Namespace

Drupal\quail_api

Code

public static function get_severity($severity = NULL) {
  $severitys =& drupal_static('quail_api_' . __FUNCTION__, NULL);
  if (!isset($severitys)) {
    if ($cache = \Drupal::cache()
      ->get('quail_api_severity')) {
      $severitys = $cache->data;
    }
    else {
      \Drupal::moduleHandler()
        ->alter('quail_api_severity', $severitys, $severity);
    }
  }
  if (isset($severitys)) {
    if (!is_null($severity)) {
      if (isset($severitys[$severity])) {
        return $severitys[$severity];
      }
      return [];
    }
    return $severitys;
  }
  $severitys = [];
  $severitys[1] = [
    'machine_name' => 'quail_test_major',
    'human_name' => t("Major Problems"),
    'module' => 'quail_api',
    'description' => t("Major problems represent critical failures in accessibility compliance."),
    'id' => 1,
    // QUAIL_TEST_SEVERE
    'default' => TRUE,
  ];
  $severitys[2] = [
    'machine_name' => 'quail_test_minor',
    'human_name' => t("Minor Problems"),
    'module' => 'quail_api',
    'description' => t("Minor problems represent simple failures in accessibility compliance."),
    'id' => 2,
    // QUAIL_TEST_MODERATE
    'default' => TRUE,
  ];
  $severitys[3] = [
    'machine_name' => 'quail_test_suggestion',
    'human_name' => t("Suggestions"),
    'module' => 'quail_api',
    'description' => t("Suggestions provide notes and tips on how to improve accessibility compliance."),
    'id' => 3,
    // QUAIL_TEST_SUGGESTION
    'default' => TRUE,
  ];
  \Drupal::cache()
    ->set('quail_api_severity', $severitys);
  if (!is_null($severity)) {
    if (isset($severitys[$severity])) {
      return $severitys[$severity];
    }
    return [];
  }
  return $severitys;
}