<?php

use MintyPHP\Module\Audit\AuditAuthorizationPolicy;
use MintyPHP\Module\Audit\Service\ImportAuditService;
use MintyPHP\Module\Audit\Support\AuditPageHelper;
use MintyPHP\Router;
use MintyPHP\Support\Flash;

AuditPageHelper::requirePurgePost(
    AuditAuthorizationPolicy::ABILITY_IMPORTS_AUDIT_PURGE,
    'audit/import-audit',
    'import_audit'
);

$deleted = app(ImportAuditService::class)->purgeExpired();
Flash::success(sprintf(t('%d import audit entries purged'), $deleted), 'audit/import-audit', 'import_audit_purged');
Router::redirect('audit/import-audit');
