function mailgun_requirements in Mailgun 8
Same name and namespace in other branches
- 7 mailgun.install \mailgun_requirements()
Implements hook_requirements().
File
- ./
mailgun.install, line 43 - Contains install/uninstall stuff.
Code
function mailgun_requirements($phase) {
$requirements = [];
if ($phase !== 'runtime') {
return $requirements;
}
$requirements = [
'mailgun' => [
'title' => t('Mailgun'),
],
];
/** @var \Drupal\mailgun\MailgunHandlerInterface $mailgun */
$mailgun_handler = \Drupal::service('mailgun.mail_handler');
if ($mailgun_handler
->validateMailgunLibrary() === FALSE) {
$requirements['mailgun']['value'] = t('The Mailgun library has not been installed correctly.');
$requirements['mailgun']['severity'] = REQUIREMENT_ERROR;
}
else {
if ($mailgun_handler
->validateMailgunApiSettings() === FALSE) {
$requirements['mailgun']['value'] = t('The Mailgun library is installed but API settings are not configured. Please check your @link.', [
'@link' => Link::createFromRoute(t('settings'), 'mailgun.admin_settings_form')
->toString(),
]);
$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;
}