function sendgrid_integration_requirements in SendGrid Integration 7
Same name and namespace in other branches
- 8.2 sendgrid_integration.install \sendgrid_integration_requirements()
- 8 sendgrid_integration.install \sendgrid_integration_requirements()
Implements hook_requirements().
File
- ./
sendgrid_integration.install, line 36 - Contains install and update functions for SendGrid Integration
Code
function sendgrid_integration_requirements($phase) {
$requirements = [];
$apikey = variable_get('sendgrid_integration_apikey', NULL);
switch ($phase) {
case 'install':
$dir = drupal_get_path('module', 'sendgrid_integration') . '/vendor/composer';
if (module_exists('xautoload') && file_exists($dir)) {
xautoload()->adapter
->composerDir($dir);
}
if (!class_exists(Client::class)) {
$requirements['sendgrid_integration'] = [
'title' => t('SendGrid API Wrapper'),
'value' => t('API Wrapper Library Missing'),
'severity' => REQUIREMENT_ERROR,
'description' => t('You need to install the SendGrid API wrapper via one of the two methods documented in the README.md of the module.'),
];
}
else {
$requirements['sendgrid_integration'] = [
'title' => t('SendGrid API Wrapper'),
'severity' => REQUIREMENT_OK,
'value' => t('API wrapper installed.'),
];
}
break;
case 'runtime':
if (empty($apikey)) {
$requirements['sendgrid_integration'] = [
'title' => t('SendGrid Integration Settings'),
'value' => t('API Key Not Set'),
'severity' => REQUIREMENT_ERROR,
'description' => t('You need to <a href="@url">add a SendGrid API Secret Key</a> for Drupal to be able to deliver mail through SendGrid Integration.', [
'@url' => url('admin/config/services/sendgrid'),
]),
];
}
else {
$requirements['sendgrid_integration'] = [
'title' => t('SendGrid Integration Settings'),
'severity' => REQUIREMENT_OK,
'value' => t('API Secret Key saved'),
];
}
break;
}
return $requirements;
}