<?php declare(strict_types=1);
namespace Memo\PostcodenlPlugin\Subscribers;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class FrontendSubscriber implements EventSubscriberInterface
{
private $configService;
public function __construct(
SystemConfigService $configService
)
{
$this->configService = $configService;
}
public static function getSubscribedEvents()
{
return [
StorefrontRenderEvent::class => "onStorefrontRender",
];
}
public function onStorefrontRender(StorefrontRenderEvent $event)
{
$config = $this->configService->get('memoPostcodePlugin.config') ?? [];
$config = array_intersect_key($config, array_diff_key($config, array_flip(['apiKey', 'apiSecret'])));
$event->setParameter('postcode_config', (object)$config);
}
}