You are here

evercurrent.module in Evercurrent 8

Same filename and directory in other branches
  1. 8.2 evercurrent.module
  2. 7.2 evercurrent.module
  3. 7 evercurrent.module

Contains evercurrent.module.

File

evercurrent.module
View source
<?php

/**
 * @file
 * Contains evercurrent.module.
 */
use Drupal\evercurrent\UpdateHelper;

/**
 * Default target environment
 */
const RMH_ENV_URL = 'https://app.evercurrent.io';

/**
 * Module's API version.
 */
const RMH_API_VERSION = 2;

/**
 * MD5 hash used for keys.
 */
const RMH_MD5_MATCH = '/^[a-f0-9]{32}$/i';

/**
 * Server update url.
 */
const RMH_URL = '/evercurrent/post-update';

/**
 * The current status of the module operation.
 */
const RMH_STATUS = 'evercurrent_status';

/**
 * Module operation: Status OK.
 * Under normal circumstances.
 */
const RMH_STATUS_OK = 0;
const RMH_STATUS_WARNING = 1;
const RMH_STATUS_ERROR = 2;

/**
 * Module status message
 *
 * Used to display current status in the status page.
 */
const RMH_STATUS_MESSAGE = 'status_message';

/**
 * Implements hook_cron().
 */
function evercurrent_cron() {
  $config = \Drupal::config('evercurrent.admin_config');

  // Check if we are to send updates now.
  if ($config
    ->get('send')) {
    $last_run = Drupal::state()
      ->get('evercurrent_last_run') ?: 0;
    $interval = $config
      ->get('interval');

    // Check if last run plus interval is earlier than now
    if ($last_run + $interval < time()) {

      /** @var UpdateHelper $updateHelper */
      $updateHelper = \Drupal::service('evercurrent.update_helper');
      $updateHelper
        ->sendUpdates(TRUE);
    }
  }
}

Functions

Namesort descending Description
evercurrent_cron Implements hook_cron().

Constants

Namesort descending Description
RMH_API_VERSION Module's API version.
RMH_ENV_URL Default target environment
RMH_MD5_MATCH MD5 hash used for keys.
RMH_STATUS The current status of the module operation.
RMH_STATUS_ERROR
RMH_STATUS_MESSAGE Module status message
RMH_STATUS_OK Module operation: Status OK. Under normal circumstances.
RMH_STATUS_WARNING
RMH_URL Server update url.