You are here

function nodejs_requirements in Node.js integration 8

Same name and namespace in other branches
  1. 7 nodejs.install \nodejs_requirements()

Implements hook_requirements()

File

./nodejs.install, line 46
Install, update and uninstall functions for the nodejs module.

Code

function nodejs_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $nodejs = \Drupal::service('nodejs.nodejs');
  $value = t('The Node.js server was successfully reached.');
  $severity = REQUIREMENT_OK;
  if (!$nodejs
    ->healthCheck()) {
    $value = t('Error reaching the Node.js server. Enable HTTP error-logging and check the dblog page for more details');
    $severity = REQUIREMENT_ERROR;
  }
  else {
    if (!$nodejs
      ->safeNodeServerVersion()) {
      $value = t('The Drupal-Node.js application version is insecure. Please update.');
      $severity = REQUIREMENT_ERROR;
    }
  }
  return [
    'nodejs' => [
      'title' => t('Node.js'),
      'description' => t('Can Drupal connect to the Node.js server?'),
      'value' => $value,
      'severity' => $severity,
    ],
  ];
}