<?php
namespace App\Utils\OrderCreator\Event\Handler;
use App\Utils\OrderCreator\Event\OrderPlacingStarted;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
#[AsEventListener(event: OrderPlacingStarted::class)]
final class ClearUserAccessCacheHandler
{
public function __construct(
private readonly CacheItemPoolInterface $cache,
) {
}
public function __invoke(OrderPlacingStarted $event): void
{
$userId = $event->getUserId();
$this->cache->deleteItem($userId . '_access');
$this->cache->deleteItem($userId . '_new_access');
}
}