<?php

use MintyPHP\Buffer;
use MintyPHP\Router;
use MintyPHP\Service\Access\OperationsAuthorizationPolicy;
use MintyPHP\Service\Audit\SystemAuditService;
use MintyPHP\Support\Flash;
use MintyPHP\Support\Guard;

Guard::requireLogin();
Guard::requireAbility(OperationsAuthorizationPolicy::ABILITY_ADMIN_SYSTEM_AUDIT_VIEW);

$auditId = (int) ($id ?? 0);
$auditLog = $auditId > 0 ? app(SystemAuditService::class)->find($auditId) : null;
if (!$auditLog) {
    Flash::error(t('System audit entry not found'), 'admin/system-audit', 'system_audit_not_found');
    Router::redirect('admin/system-audit');
}

Buffer::set('title', t('View system audit entry'));
