You are here

function queue_mail_requirements in Queue Mail 8

Same name and namespace in other branches
  1. 5 queue_mail.install \queue_mail_requirements()
  2. 6 queue_mail.install \queue_mail_requirements()
  3. 7 queue_mail.install \queue_mail_requirements()

Implements hook_requirements().

File

./queue_mail.install, line 27
Install, update and uninstall functions for the Queue Mail module.

Code

function queue_mail_requirements($phase) {
  $requirements = [];
  switch ($phase) {
    case 'runtime':
      $queue_length = _queue_mail_get_queue()
        ->numberOfItems();
      $requirements['queue_mail'] = [
        'title' => t('Queue mail'),
        'value' => \Drupal::translation()
          ->formatPlural($queue_length, '1 mail currently queued for sending.', '@count mails currently queued for sending.'),
        'description' => [
          [
            '#markup' => t('Sending of queued mails happens on cron.'),
            '#suffix' => ' ',
          ],
          [
            '#markup' => t('You can <a href=":cron">run cron manually</a>.', [
              ':cron' => Url::fromRoute('system.run_cron')
                ->toString(),
            ]),
            '#prefix' => '<br/>',
          ],
        ],
        'severity' => $queue_length > 0 ? REQUIREMENT_INFO : REQUIREMENT_OK,
      ];
      break;
  }
  return $requirements;
}