<?php declare(strict_types=1);
namespace Weedesign\Images2WebP\Listener;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Shopware\Core\System\SystemConfig\SystemConfigService;
class ResponseListener
{
private SystemConfigService $systemConfigService;
public function __construct(
SystemConfigService $systemConfigService
)
{
$this->systemConfigService = $systemConfigService;
}
/**
* @param ResponseEvent $event
*/
public function onKernelResponse(ResponseEvent $event): void
{
if ($this->systemConfigService->get('WeedesignImages2WebP.config.webpFrontend')) {
$this->systemConfigService->set('WeedesignImages2WebP.config.webpCount', 0);
} else {
$this->systemConfigService->set('WeedesignImages2WebP.config.webpCount', $this->systemConfigService->get('WeedesignImages2WebP.config.webpInt'));
}
}
}