custom/plugins/NeonPasswordView/src/Storefront/Subscriber/ThemeVariableSubscriber.php line 32

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace NeonPasswordView\Storefront\Subscriber;
  4. use Shopware\Core\System\SystemConfig\SystemConfigService;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Shopware\Storefront\Theme\Event\ThemeCompilerEnrichScssVariablesEvent;
  7. class ThemeVariableSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var SystemConfigService
  11.      */
  12.     protected $systemConfig;
  13.     public function __construct(SystemConfigService $systemConfig)
  14.     {
  15.         $this->systemConfig $systemConfig;
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             ThemeCompilerEnrichScssVariablesEvent::class => 'onAddVariables'
  21.         ];
  22.     }
  23.     public function onAddVariables(ThemeCompilerEnrichScssVariablesEvent $event)
  24.     {
  25.         $configFields $this->systemConfig->get('NeonPasswordView.config'$event->getSalesChannelId());
  26.         $event->addVariable(
  27.             'passwordMarginTop',
  28.             (array_key_exists('marginTop'$configFields) ? $configFields['marginTop'] : '8') . 'px'
  29.         );
  30.         $event->addVariable(
  31.             'passwordMarginRight',
  32.             (array_key_exists('marginRight'$configFields) ? $configFields['marginRight'] : '16') . 'px'
  33.         );
  34.         $event->addVariable(
  35.             'passwordSize',
  36.             (array_key_exists('size'$configFields) ? $configFields['size'] : '24') . 'px'
  37.         );
  38.     }
  39. }