public function PostUpdateSubscriber::onPostUpdate in Automatic Updates 8
Send notification on post update with success/failure.
Parameters
\Drupal\automatic_updates\Event\PostUpdateEvent $event: The post update event.
File
- src/
EventSubscriber/ PostUpdateSubscriber.php, line 82
Class
- PostUpdateSubscriber
- Post update event subscriber.
Namespace
Drupal\automatic_updates\EventSubscriberCode
public function onPostUpdate(PostUpdateEvent $event) {
$notify_list = $this->configFactory
->get('update.settings')
->get('notification.emails');
if (!empty($notify_list)) {
$params['subject'] = $this
->t('Automatic update of "@project" succeeded', [
'@project' => $event
->getUpdateMetadata()
->getProjectName(),
]);
if (!$event
->success()) {
$params['subject'] = $this
->t('Automatic update of "@project" failed', [
'@project' => $event
->getUpdateMetadata()
->getProjectName(),
]);
}
$params['body'] = [
'#theme' => 'automatic_updates_post_update',
'#success' => $event
->success(),
'#metadata' => $event
->getUpdateMetadata(),
];
$default_langcode = $this->languageManager
->getDefaultLanguage()
->getId();
$params['langcode'] = $default_langcode;
foreach ($notify_list as $to) {
$this
->doSend($to, $params);
}
}
}