You are here

function reroute_email_requirements in Reroute Email 8

Same name and namespace in other branches
  1. 7 reroute_email.install \reroute_email_requirements()
  2. 2.x reroute_email.install \reroute_email_requirements()

Implements hook_requirements().

File

./reroute_email.install, line 13
Reroute Email installation and upgrade tasks.

Code

function reroute_email_requirements($phase) {
  $requirements = [];
  $reroute_config = \Drupal::config('reroute_email.settings');
  if ($phase === 'runtime' && $reroute_config
    ->get(REROUTE_EMAIL_ENABLE)) {
    $settings = [
      '@link' => Link::createFromRoute(t('configure whitelist'), 'reroute_email.settings')
        ->toString(),
      '%addresses' => $reroute_config
        ->get(REROUTE_EMAIL_ADDRESS),
    ];
    if (empty($settings['%addresses'])) {
      $message = t('All outgoing emails (@link) would be aborted and recorded in the recent log entries (if enabled).', $settings);
    }
    else {
      $message = t('All outgoing emails (@link) would be rerouted to: %addresses', $settings);
    }
    $requirements['reroute_email'] = [
      'title' => t('Reroute Email'),
      'value' => $message,
      'severity' => REQUIREMENT_WARNING,
    ];
  }
  return $requirements;
}