public function DevelMailLoggerController::showMail in Devel Mail Logger 8
Show a single mail.
1 string reference to 'DevelMailLoggerController::showMail'
File
- src/
Controller/ DevelMailLoggerController.php, line 135
Class
- DevelMailLoggerController
- Class DevelMailLoggerController.
Namespace
Drupal\devel_mail_logger\ControllerCode
public function showMail($id) {
$build = [];
$mail_log = $this->database
->query('SELECT * FROM {devel_mail_logger} m WHERE m.id = :id', [
':id' => $id,
])
->fetchObject();
$mail = json_decode($mail_log->message);
$rows = [];
foreach ($mail->headers as $key => $value) {
$rows[] = [
[
'data' => $key,
'header' => TRUE,
],
$value,
];
}
$build['headers'] = [
'#type' => 'details',
'#title' => 'Headers',
];
$build['headers']['table'] = [
'#type' => 'table',
'#rows' => $rows,
'#attributes' => [
'class' => [
'table table__header',
],
],
];
$rows = [
[
[
'data' => $this
->t('To: '),
'header' => TRUE,
],
$mail->to,
],
[
[
'data' => $this
->t('Subject: '),
'header' => TRUE,
],
$mail->subject,
],
[
[
'data' => $this
->t('Body: '),
'header' => TRUE,
],
Markup::create(nl2br(is_array($mail->body) ? implode('', $mail->body) : $mail->body)),
],
];
$build['mail_table'] = [
'#type' => 'table',
'#rows' => $rows,
'#attributes' => [
'class' => [
'table table__content',
],
],
];
return $build;
}