<?php

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

AuditPageHelper::requirePurgePost(
    AuditAuthorizationPolicy::ABILITY_API_AUDIT_PURGE,
    'audit/api-audit',
    'api_audit'
);

$deleted = app(ApiAuditService::class)->purgeExpired();
Flash::success(sprintf(t('%d API audit entries purged'), $deleted), 'audit/api-audit', 'api_audit_purged');
Router::redirect('audit/api-audit');
