<?php declare(strict_types=1);
namespace Okeonline\KejeLogin\Storefront\Page\Subscriber;
use Shopware\Core\Framework\Struct\ArrayStruct;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Page\GenericPageLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class GenericPageLoadedEventSubscriber implements EventSubscriberInterface
{
protected $systemConfigService;
public function __construct(
SystemConfigService $systemConfigService
)
{
$this->systemConfigService = $systemConfigService;
}
public static function getSubscribedEvents()
{
return [
GenericPageLoadedEvent::class => 'onPageLoaded'
];
}
public function onPageLoaded(GenericPageLoadedEvent $event)
{
if($event->getRequest()->get('_route') !== 'frontend.account.login.page'){
return;
}
$event->getPage()->addExtension('OkeonlineKejeLogin', new ArrayStruct([
'active' => $this->systemConfigService->get('OkeonlineKejeLogin.config.active'),
'identifier' => $this->systemConfigService->get('OkeonlineKejeLogin.config.identifier'),
'identifierLabel' => $this->systemConfigService->get('OkeonlineKejeLogin.config.identifierLabel')
]));
}
}