<?php declare(strict_types=1);
namespace Dmits\InfoFlag\Storefront\Subscriber;
use Dmits\InfoFlag\Struct\InfoFlag;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Sorting\FieldSorting;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FooterSubscriber implements EventSubscriberInterface
{
/**
* @var SystemConfigService
*/
private $systemConfigService;
/**
* @var EntityRepositoryInterface
*/
private $infoFlagRepository;
public function __construct(
SystemConfigService $systemConfigService
) {
$this->systemConfigService = $systemConfigService;
}
public static function getSubscribedEvents(): array
{
return [
FooterPageletLoadedEvent::class => 'onFooterPageletLoaded',
];
}
public function onFooterPageletLoaded(FooterPageletLoadedEvent $event): void
{
$infoflag = new InfoFlag();
$infoflag->setActive($this->systemConfigService->getBool('DmitsInfoFlag.config.active'));
$infoflag->setPosition($this->systemConfigService->getString('DmitsInfoFlag.config.position'));
$infoflag->setWidth($this->systemConfigService->getString('DmitsInfoFlag.config.width'));
$infoflag->setHeight($this->systemConfigService->getString('DmitsInfoFlag.config.height'));
$infoflag->setTextcolor($this->systemConfigService->getString('DmitsInfoFlag.config.textcolor'));
$infoflag->setBgcolor($this->systemConfigService->getString('DmitsInfoFlag.config.bgcolor'));
$infoflag->setClosetextcolor($this->systemConfigService->getString('DmitsInfoFlag.config.closetextcolor'));
$infoflag->setClosebgcolor($this->systemConfigService->getString('DmitsInfoFlag.config.closebgcolor'));
$infoflag->setCloseborderradius($this->systemConfigService->getString('DmitsInfoFlag.config.closeborderradius'));
$infoflag->setClosetime($this->systemConfigService->getString('DmitsInfoFlag.config.closetime'));
$infoflag->setContentpadding($this->systemConfigService->getString('DmitsInfoFlag.config.contentpadding'));
$infoflag->setBorder($this->systemConfigService->getBool('DmitsInfoFlag.config.border'));
$infoflag->setClose($this->systemConfigService->getBool('DmitsInfoFlag.config.close'));
$infoflag->setContent($this->systemConfigService->getString('DmitsInfoFlag.config.content'));
$infoflag->setMobile($this->systemConfigService->getBool('DmitsInfoFlag.config.mobile'));
$infoflag->setMobileland($this->systemConfigService->getBool('DmitsInfoFlag.config.mobileland'));
$infoflag->setTablet($this->systemConfigService->getBool('DmitsInfoFlag.config.tablet'));
$infoflag->setTabletland($this->systemConfigService->getBool('DmitsInfoFlag.config.tabletland'));
$infoflag->setDesktop($this->systemConfigService->getBool('DmitsInfoFlag.config.desktop'));
$event->getPagelet()->addExtension('dmitsInfoFlag', $infoflag);
}
}