custom/plugins/HuebertSeoUltimate/src/Subscriber/ThemeVariablesSubscriber.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Huebert\SeoUltimate\Subscriber;
  3. use Shopware\Core\Defaults;
  4. use Shopware\Storefront\Event\ThemeCompilerEnrichScssVariablesEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Shopware\Core\System\SystemConfig\SystemConfigService;
  7. class ThemeVariablesSubscriber implements EventSubscriberInterface
  8. {
  9.     /*
  10.      * @var SystemConfigService
  11.      */
  12.     private $systemConfig;
  13.     // add the `SystemConfigService` to your constructor
  14.     public function __construct(SystemConfigService $systemConfig)
  15.     {
  16.         $this->systemConfig $systemConfig;
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             ThemeCompilerEnrichScssVariablesEvent::class => 'onAddVariables'
  22.         ];
  23.     }
  24.     public function onAddVariables(ThemeCompilerEnrichScssVariablesEvent $event)
  25.     {
  26.         $languageId Defaults::LANGUAGE_SYSTEM;
  27.         $newsletterColorBg $this->systemConfig->get('HuebertSeoUltimate.config.conversion.newsletter.'.$languageId.'.colorBg'$event->getSalesChannelId());
  28.         $newsletterColorText $this->systemConfig->get('HuebertSeoUltimate.config.conversion.newsletter.'.$languageId.'.colorText'$event->getSalesChannelId());
  29.         if($newsletterColorBg) {$event->addVariable('hueb-seo-newsletter-colorBg'$newsletterColorBg);}
  30.         if($newsletterColorText) {$event->addVariable('hueb-seo-newsletter-colorText'$newsletterColorText);}
  31.         $headerColorBg $this->systemConfig->get('HuebertSeoUltimate.config.conversion.header.'.$languageId.'.colorBg'$event->getSalesChannelId());
  32.         $headerColorText $this->systemConfig->get('HuebertSeoUltimate.config.conversion.header.'.$languageId.'.colorText'$event->getSalesChannelId());
  33.         if($headerColorBg) {$event->addVariable('hueb-seo-header-colorBg'$headerColorBg);}
  34.         if($headerColorText) {$event->addVariable('hueb-seo-header-colorText'$headerColorText);}
  35.         $socialmediaColorBg $this->systemConfig->get('HuebertSeoUltimate.config.conversion.socialmedia.'.$languageId.'.colorBg'$event->getSalesChannelId());
  36.         $socialmediaColorText $this->systemConfig->get('HuebertSeoUltimate.config.conversion.socialmedia.'.$languageId.'.colorText'$event->getSalesChannelId());
  37.         if($socialmediaColorBg) {$event->addVariable('hueb-seo-socialmedia-colorBg'$socialmediaColorBg);}
  38.         if($socialmediaColorText) {$event->addVariable('hueb-seo-socialmedia-colorText'$socialmediaColorText);}
  39.     }
  40. }