<?php
namespace App\EventListener\Client\Store;
use App\Entity\Client\Store\StoreAlert;
use App\EventListener\GenericEvent;
use App\Service\AppManager;
use Symfony\Component\HttpFoundation\Response;
class StoreAlertDeleteListener
{
private $appManager;
public function __construct(AppManager $appManager)
{
$this->appManager = $appManager;
}
public function delete(GenericEvent $genericEvent)
{
$storeAlert = $genericEvent->getSubject();
if (!$storeAlert instanceof StoreAlert) {
return;
}
$storeAlert->setReadAt(new \DateTime());
$this->appManager->persist($storeAlert);
$genericEvent->setResponse(new Response('', 204));
$genericEvent->stopPropagation();
}
}