<?php
// pages/components/invalidate_flow_cache.php
// Invalidates the flow cache for a specific resource and triggers a refresh event.

use Components\Support\FlowCache;

// Always buffer inline HTML per rendering conventions
ob_start();

$id = ($_REQUEST['id'] ?? 0);
$type = (string)($_REQUEST['type'] ?? 'newsletter_item');
$eventPrefix = (string)($_REQUEST['event_prefix'] ?? $type);

FlowCache::invalidate($type, $id, [
    'event_prefix' => $eventPrefix,
    'flush' => true,
]);

echo ob_get_clean();
