You are here

function warden_requirements in Warden 7

Same name and namespace in other branches
  1. 8.2 warden.install \warden_requirements()
  2. 8 warden.install \warden_requirements()
  3. 6 warden.install \warden_requirements()
  4. 3.x warden.install \warden_requirements()

Implements hook_requirements().

File

./warden.install, line 30
Clean up file for warden

Code

function warden_requirements($phase) {
  $requirements = array();
  $t = get_t();
  $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 PHP OpenSSL extension needs to be installed to communicate with Warden - ') . l(t('PHP Manual'), 'http://php.net/manual/en/openssl.installation.php'),
    'severity' => $ssl_available ? REQUIREMENT_OK : REQUIREMENT_ERROR,
  );
  if ($phase == 'runtime') {
    $warden_available = FALSE;
    $error = '';
    try {
      warden_get_api()
        ->getPublicKey();
      $warden_available = TRUE;
    } catch (Exception $e) {
      $error = $e
        ->getMessage();
      $warden_available = FALSE;
    }
    $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'),
      'description' => check_plain($error),
      'severity' => $warden_available ? REQUIREMENT_OK : REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}