automatic_updates-8.x-2.x-dev/tests/modules/automatic_updates_test/automatic_updates_test.module
tests/modules/automatic_updates_test/automatic_updates_test.module
<?php
/**
* @file
* Contains hook implementations for testing Automatic Updates.
*/
declare(strict_types=1);
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* Implements hook_mail_alter().
*/
function automatic_updates_test_mail_alter(array &$message): void {
if (str_starts_with($message['id'], 'automatic_updates_')) {
$line_langcodes = [];
// Get the langcode of every translated line in the message, including the
// subject line.
$lines = array_merge($message['body'], [
$message['subject'],
]);
foreach ($lines as $line) {
if ($line instanceof TranslatableMarkup) {
$line_langcodes[] = $line->getOption('langcode');
}
}
$message['line_langcodes'] = array_unique($line_langcodes);
}
}
