You are here

protected function PostUpdateSubscriber::doSend in Automatic Updates 8

Composes and send the email message.

Parameters

string $to: The email address where the message will be sent.

array $params: Parameters to build the email.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to PostUpdateSubscriber::doSend()
PostUpdateSubscriber::onPostUpdate in src/EventSubscriber/PostUpdateSubscriber.php
Send notification on post update with success/failure.

File

src/EventSubscriber/PostUpdateSubscriber.php, line 113

Class

PostUpdateSubscriber
Post update event subscriber.

Namespace

Drupal\automatic_updates\EventSubscriber

Code

protected function doSend($to, array $params) {
  $users = $this->entityTypeManager
    ->getStorage('user')
    ->loadByProperties([
    'mail' => $to,
  ]);
  foreach ($users as $user) {
    $to_user = reset($users);
    $params['langcode'] = $to_user
      ->getPreferredLangcode();
    $this->mailManager
      ->mail('automatic_updates', 'post_update', $to, $params['langcode'], $params);
  }
}