<?php
declare(strict_types=1);
namespace NeonPasswordView\Storefront\Subscriber;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Theme\Event\ThemeCompilerEnrichScssVariablesEvent;
class ThemeVariableSubscriber implements EventSubscriberInterface
{
/**
* @var SystemConfigService
*/
protected $systemConfig;
public function __construct(SystemConfigService $systemConfig)
{
$this->systemConfig = $systemConfig;
}
public static function getSubscribedEvents(): array
{
return [
ThemeCompilerEnrichScssVariablesEvent::class => 'onAddVariables'
];
}
public function onAddVariables(ThemeCompilerEnrichScssVariablesEvent $event)
{
$configFields = $this->systemConfig->get('NeonPasswordView.config', $event->getSalesChannelId());
$event->addVariable(
'passwordMarginTop',
(array_key_exists('marginTop', $configFields) ? $configFields['marginTop'] : '8') . 'px'
);
$event->addVariable(
'passwordMarginRight',
(array_key_exists('marginRight', $configFields) ? $configFields['marginRight'] : '16') . 'px'
);
$event->addVariable(
'passwordSize',
(array_key_exists('size', $configFields) ? $configFields['size'] : '24') . 'px'
);
}
}