<?php
namespace App\EventListener\Client\Store;
use App\Entity\Client\Store\StoreHeader;
use App\EventListener\GenericEvent;
use App\Service\Client\Store\StoreHeaderManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
class StoreHeaderListener
{
private $storeHeaderManager;
public function __construct(StoreHeaderManager $storeHeaderManager)
{
$this->storeHeaderManager = $storeHeaderManager;
}
public function pre(GenericEvent $genericEvent)
{
$storeHeader = $genericEvent->getSubject();
if (!$storeHeader instanceof StoreHeader) {
return;
}
$this->storeHeaderManager->pre($genericEvent);
}
public function post(GenericEvent $genericEvent)
{
$storeHeader = $genericEvent->getSubject();
if (!$storeHeader instanceof StoreHeader) {
return;
}
$this->storeHeaderManager->post($genericEvent);
}
public function confirm(GenericEvent $genericEvent)
{
$storeHeader = $genericEvent->getSubject();
if (!$storeHeader instanceof StoreHeader) {
return;
}
set_time_limit(300);
$this->storeHeaderManager->confirm($storeHeader);
}
public function delete(GenericEvent $genericEvent)
{
$storeHeader = $genericEvent->getSubject();
if (!$storeHeader instanceof StoreHeader) {
return;
}
if (!$storeHeader->isTemporary()){
throw new HttpException(400, 'Header is not temporary');
}
}
}