You are here

warden.install in Warden 8

Same filename and directory in other branches
  1. 8.2 warden.install
  2. 6 warden.install
  3. 7 warden.install
  4. 3.x warden.install

Clean up file for warden

File

warden.install
View source
<?php

/**
 * @file
 * Clean up file for warden
 */

/**
 * Implements hook_requirements().
 */
function warden_requirements($phase) {
  $requirements = array();
  $ssl_available = function_exists('openssl_seal');
  $requirements['warden_openssl'] = array(
    'title' => t('Warden'),
    'value' => $ssl_available ? t('Open SSL is available') : t('Open SSL is not available'),
    'description' => t('The <a href="@url">PHP OpenSSL</a> extension needs to be available to communicate with Warden', array(
      '@url' => 'http://php.net/manual/en/openssl.installation.php',
    )),
    'severity' => $ssl_available ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  );
  if ($phase == 'runtime') {
    $warden_available = FALSE;
    $error = '';
    $url = \Drupal::service('warden.manager')
      ->getWardenUrl();
    try {
      if (empty($url)) {
        throw new \Exception(t('Warden server URL is not configured. Read the README for more information.'));
      }
      \Drupal::service('warden.manager')
        ->getPublicKey();
      $warden_available = TRUE;
    } catch (\Exception $e) {
      $error = $e
        ->getMessage();
    }
    $requirements['warden_available'] = array(
      'title' => t('Warden available'),
      'value' => $warden_available ? t('The Warden server can be contacted') : t('The Warden server cannot be contacted'),
      'severity' => $warden_available ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );
    if (empty($warden_available)) {
      $requirements['warden_available']['description'] = t('Error message: :message', array(
        ':message' => $error,
      ));
    }
    else {
      $requirements['warden_available']['description'] = t('Configured Warden server URL: :url', array(
        ':url' => $url,
      ));
    }
  }
  return $requirements;
}

Functions

Namesort descending Description
warden_requirements Implements hook_requirements().