<?php

use MintyPHP\Buffer;
use MintyPHP\Router;
use MintyPHP\Service\Access\PermissionService;
use MintyPHP\Service\Import\ImportServicesFactory;
use MintyPHP\Support\Flash;
use MintyPHP\Support\Guard;

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

$runId = (int) ($id ?? 0);
$factory = new ImportServicesFactory();
$auditRun = $runId > 0 ? $factory->createImportAuditService()->find($runId) : null;
if (!$auditRun) {
    Flash::error(t('Import audit entry not found'), 'admin/import-audit', 'import_audit_not_found');
    Router::redirect('admin/import-audit');
}

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