<?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_API_AUDIT_VIEW);

$auditId = (int) ($id ?? 0);
$auditLog = $auditId > 0 ? app(\MintyPHP\Service\Audit\ApiAuditService::class)->find($auditId) : null;
if (!$auditLog) {
    Flash::error('API audit entry not found', 'admin/api-audit', 'api_audit_not_found');
    Router::redirect('admin/api-audit');
}

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