custom/plugins/ImnxxNavigationBanner/src/Subscriber/ThemeVariableSubscriber.php line 24

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace ImnxxNavigationBanner\Subscriber;
  3. use Shopware\Core\System\SystemConfig\SystemConfigService;
  4. use Shopware\Storefront\Event\ThemeCompilerEnrichScssVariablesEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class ThemeVariableSubscriber implements EventSubscriberInterface
  7. {
  8.     protected SystemConfigService $systemConfig;
  9.     public function __construct(SystemConfigService $systemConfig)
  10.     {
  11.         $this->systemConfig $systemConfig;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             ThemeCompilerEnrichScssVariablesEvent::class => 'onAddVariables'
  17.         ];
  18.     }
  19.     public function onAddVariables(ThemeCompilerEnrichScssVariablesEvent $event): void
  20.     {
  21.         $configPluginNavigationBannerBgColor $this->systemConfig->get('ImnxxNavigationBanner.config.navigationBannerBackgroundColor'$event->getSalesChannelId());
  22.         $configPluginNavigationBannerTextColor $this->systemConfig->get('ImnxxNavigationBanner.config.navigationBannerTextColor'$event->getSalesChannelId());
  23.         if ($configPluginNavigationBannerBgColor) {
  24.             $event->addVariable('imnxx-navigation-banner-bg-color'$configPluginNavigationBannerBgColor);
  25.         }
  26.         if ($configPluginNavigationBannerTextColor) {
  27.             $event->addVariable('imnxx-navigation-banner-text-color'$configPluginNavigationBannerTextColor);
  28.         }
  29.     }
  30. }