<?php

use MintyPHP\Buffer;
use MintyPHP\Router;
use MintyPHP\Support\Flash;
use MintyPHP\Support\Guard;
use MintyPHP\Service\Access\PermissionService;
use MintyPHP\Service\Audit\AuditServicesFactory;

Guard::requireLogin();
Guard::requirePermission(PermissionService::API_AUDIT_VIEW);

$auditId = (int) ($id ?? 0);
$factory = new AuditServicesFactory();
$auditLog = $auditId > 0 ? $factory->createApiAuditService()->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'));
