You are here

function webprofiler_requirements in Devel 8.2

Same name and namespace in other branches
  1. 8.3 webprofiler/webprofiler.install \webprofiler_requirements()
  2. 8 webprofiler/webprofiler.install \webprofiler_requirements()
  3. 4.x webprofiler/webprofiler.install \webprofiler_requirements()

Implements hook_requirements().

File

webprofiler/webprofiler.install, line 88
Install, update and uninstall functions for the webprofiler module.

Code

function webprofiler_requirements($phase) {
  $requirements = [];
  if ('runtime' == $phase) {
    $has_d3 = _webprofiler_verify_library('webprofiler', 'd3');
    $requirements['d3js'] = [
      'title' => t('D3.js library'),
      'value' => $has_d3 ? t('Enabled') : t('Not found'),
    ];
    if (!$has_d3) {
      $requirements['d3js']['severity'] = REQUIREMENT_WARNING;
      $requirements['d3js']['description'] = [
        '#prefix' => ' ',
        '#markup' => t('Webprofiler module requires D3.js library to properly render data. Composer based install recommended, see README.md file for instructions.'),
      ];
    }
    $has_highlight = _webprofiler_verify_library('webprofiler', 'highlightjs');
    $requirements['highlightjs'] = [
      'title' => t('highlight.js library'),
      'value' => $has_highlight ? t('Enabled') : t('Not found'),
    ];
    if (!$has_highlight) {
      $requirements['highlightjs']['severity'] = REQUIREMENT_WARNING;
      $requirements['highlightjs']['description'] = [
        '#prefix' => ' ',
        '#markup' => t('Webprofiler module requires highlight.js library to syntax highlight collected queries. Composer based install recommended, see README.md file for instructions.'),
      ];
    }
  }
  return $requirements;
}