<?php

use MintyPHP\Buffer;
use MintyPHP\Router;
use MintyPHP\Support\Flash;
use MintyPHP\Support\Guard;

Guard::requireLogin();
Guard::requireAbility(\MintyPHP\Service\Access\OperationsAuthorizationPolicy::ABILITY_ADMIN_MAIL_LOG_VIEW);

$mailLogId = (int) ($id ?? 0);
$mailLogService = app(\MintyPHP\Service\Mail\MailLogService::class);
$mailLog = $mailLogId > 0 ? $mailLogService->find($mailLogId) : null;
if (!$mailLog) {
    Flash::error('Mail log not found', 'admin/mail-log', 'mail_log_not_found');
    Router::redirect('admin/mail-log');
}

Buffer::set('title', t('View mail log'));
$breadcrumbs = [
    ['label' => t('Home'), 'path' => 'admin'],
    ['label' => t('Mail logs'), 'path' => 'admin/mail-log'],
    ['label' => t('View')],
];
