You are here

evercurrent.install in Evercurrent 8.2

Same filename and directory in other branches
  1. 8 evercurrent.install
  2. 7.2 evercurrent.install
  3. 7 evercurrent.install

Drupal install file for RMH

File

evercurrent.install
View source
<?php

/**
 * @file Drupal install file for RMH
 */
use Drupal\evercurrent\UpdateHelper;

/**
 * Implements hook_requirements().
 *
 * Allow us to display current status in the site's status page.
 */
function evercurrent_requirements($phase) {
  $requirements = [];

  // We only do stuff at runtime.
  if ($phase !== 'runtime') {
    return $requirements;
  }
  $state = \Drupal::state();
  $config = \Drupal::config('evercurrent.admin_config');

  // Listening enabled?
  $listen = $config
    ->get('listen');
  $listen_on_text = t('The Evercurrent module is listening for a key to use.
   You should finish configuration on the server side, or turn the listening feature off
   in the settings.');
  $requirements['evercurrent_listen'] = [
    'title' => t('Evercurrent: Listening mode'),
    'value' => $listen ? t('Listening enabled') : t('Disabled'),
    'severity' => $listen ? REQUIREMENT_WARNING : REQUIREMENT_OK,
    'description' => $listen ? $listen_on_text : '',
  ];

  // Last run
  $updateHelper = \Drupal::service('evercurrent.update_helper');
  $requirements['evercurrent_last_run'] = [
    'title' => t('Evercurrent: Last successful run'),
    'value' => $updateHelper
      ->lastRun(),
    'severity' => REQUIREMENT_OK,
  ];

  // Drop last status to the panel
  $message = $state
    ->get('evercurrent_status_message') ?: t('No communication with server yet.');
  $severity = $state
    ->get('evercurrent_status');
  $severity = $severity || $severity === 0 ? $severity : RMH_STATUS_WARNING;
  $requirements['evercurrent_status'] = [
    'title' => t('Evercurrent: Runtime status'),
    'value' => $message,
    'severity' => $severity,
  ];
  return $requirements;
}

Functions

Namesort descending Description
evercurrent_requirements Implements hook_requirements().