You are here

function template_preprocess_prod_check_status_report in Production check & Production monitor 8

Prepares variables for status report template.

Default template: status-report.html.twig.

This theme function is dependent on install.inc being loaded, because that's where the constants are defined.

Parameters

$variables: An associative array containing:

  • requirements: An associative array of requirements/status items per category. Each requirement is an associative array containing the following elements:

File

./prod_check.module, line 47
Module file for the prod check module

Code

function template_preprocess_prod_check_status_report(&$variables) {
  $severities = [
    ProdCheck::REQUIREMENT_INFO => [
      'title' => t('Info'),
      'status' => 'info',
    ],
    ProdCheck::REQUIREMENT_OK => [
      'title' => t('OK'),
      'status' => 'ok',
    ],
    ProdCheck::REQUIREMENT_WARNING => [
      'title' => t('Warning'),
      'status' => 'warning',
    ],
    ProdCheck::REQUIREMENT_ERROR => [
      'title' => t('Error'),
      'status' => 'error',
    ],
  ];
  foreach ($variables['requirements'] as $category => $requirements_per_category) {
    foreach ($requirements_per_category as $i => $requirement) {

      // Always use the explicit requirement severity, if defined. Otherwise,
      // default to REQUIREMENT_OK in the installer to visually confirm that
      // installation requirements are met. And default to REQUIREMENT_INFO to
      // denote neutral information without special visualization.
      if (isset($requirement['severity'])) {
        $severity = $severities[(int) $requirement['severity']];
      }
      elseif (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') {
        $severity = $severities[ProdCheck::REQUIREMENT_OK];
      }
      else {
        $severity = $severities[ProdCheck::REQUIREMENT_INFO];
      }
      $variables['requirements'][$category][$i]['severity_title'] = $severity['title'];
      $variables['requirements'][$category][$i]['severity_status'] = $severity['status'];
    }
  }
}