You are here

queue_mail.install in Queue Mail 8

Same filename and directory in other branches
  1. 5 queue_mail.install
  2. 6 queue_mail.install
  3. 7 queue_mail.install

Install, update and uninstall functions for the Queue Mail module.

File

queue_mail.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the Queue Mail module.
 */
use Drupal\Core\Url;

/**
 * Implements hook_install().
 */
function queue_mail_install() {
  _queue_mail_get_queue()
    ->createQueue();
}

/**
 * Implements hook_uninstall().
 */
function queue_mail_uninstall() {
  _queue_mail_get_queue()
    ->deleteQueue();
}

/**
 * Implements hook_requirements().
 */
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;
}

/**
 * Set configuration settings for a retry limit.
 */
function queue_mail_update_8001() {
  \Drupal::configFactory()
    ->getEditable('queue_mail.settings')
    ->set('threshold', 50)
    ->set('requeue_interval', 10800)
    ->save();
}

/**
 * Set configuration settings for a wait time per item.
 */
function queue_mail_update_8002() {
  \Drupal::configFactory()
    ->getEditable('queue_mail.settings')
    ->set('queue_mail_queue_wait_time', 0)
    ->save();
}

/**
 * Enable "queue_mail_language" to preserve backwards-compatibility.
 */
function queue_mail_update_8003() {

  /** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
  $module_installer = \Drupal::service('module_installer');
  $module_installer
    ->install([
    'queue_mail_language',
  ]);
}

Functions

Namesort descending Description
queue_mail_install Implements hook_install().
queue_mail_requirements Implements hook_requirements().
queue_mail_uninstall Implements hook_uninstall().
queue_mail_update_8001 Set configuration settings for a retry limit.
queue_mail_update_8002 Set configuration settings for a wait time per item.
queue_mail_update_8003 Enable "queue_mail_language" to preserve backwards-compatibility.