You are here

function mailgun_requirements in Mailgun 7

Same name and namespace in other branches
  1. 8 mailgun.install \mailgun_requirements()

Implements hook_requirements().

File

./mailgun.install, line 47
Install, update and uninstall functions for the Mailgun module.

Code

function mailgun_requirements($phase) {

  // Ensure translations don't break during installation.
  $t = get_t();
  $requirements = array();
  if ($phase !== 'runtime') {
    return $requirements;
  }
  $requirements['mailgun']['title'] = $t('Mailgun');
  if (mailgun_check_library() === FALSE) {
    $requirements['mailgun']['value'] = $t('The Mailgun library has not been installed correctly.');
    $requirements['mailgun']['severity'] = REQUIREMENT_ERROR;
  }
  else {
    if (mailgun_check_api_settings() === FALSE) {
      $requirements['mailgun']['value'] = $t('The Mailgun library is installed but API settings are not configured. Please check your !link.', [
        '!link' => l($t('settings'), MAILGUN_ADMIN_PAGE),
      ]);
      $requirements['mailgun']['severity'] = REQUIREMENT_WARNING;
    }
    else {
      $requirements['mailgun']['value'] = $t('The Mailgun library is installed correctly. API settings are configured.');
      $requirements['mailgun']['severity'] = REQUIREMENT_OK;
    }
  }
  return $requirements;
}