<?php declare(strict_types=1);
namespace TraumPlugin\Storefront\Subscriber;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FooterSubscriber implements EventSubscriberInterface
{
public const CONFIG_EXTENSION_NAME = 'TraumPlugin';
/**
* @var SystemConfigService
*/
private $systemConfigService;
public function __construct(
SystemConfigService $systemConfigService
)
{
$this->systemConfigService = $systemConfigService;
}
/**
* @return string[
*/
public static function getSubscribedEvents()
{
return [FooterPageletLoadedEvent::class => 'onFooterPageletLoaded'];
}
/**
* @param FooterPageletLoadedEvent $event
*/
public function onFooterPageletLoaded(FooterPageletLoadedEvent $event)
{
if (!$this->systemConfigService->get('TraumPlugin.config.showInStorefront')) {
return;
}
$seo_text = $this->systemConfigService->get('TraumPlugin.config.text');
$config = new ConfigStruct();
$config->setSeoText($seo_text);
$event->getPagelet()->addExtension(self::CONFIG_EXTENSION_NAME, $config);
}
}