custom/plugins/AutobatMarktThemePlugin-master/src/Subscriber/FrontendAsigneesSubscriber.php line 44

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Expert\AutobatMarktThemePlugin\Subscriber;
  3. use Shopware\Core\System\SystemConfig\SystemConfigService;
  4. use Shopware\Storefront\Page\Navigation\NavigationPageLoadedEvent;
  5. use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
  6. use Shopware\Storefront\Pagelet\PageletLoadedEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  9. class FrontendAsigneesSubscriber implements EventSubscriberInterface
  10. {
  11.     /**
  12.      * Plugin Name
  13.      */
  14.     const CONFIG_NAMESPACE 'AutobatMarktThemePlugin';
  15.     /**
  16.      * @var SystemConfigService
  17.      */
  18.     private $systemConfig;
  19.     /**
  20.      * FrontendAsigneesSubscriber constructor.
  21.      *
  22.      * @param SystemConfigService $systemConfig
  23.      */
  24.     public function __construct(SystemConfigService $systemConfig)
  25.     {
  26.         $this->systemConfig $systemConfig;
  27.     }
  28.     public static function getSubscribedEvents()
  29.     {
  30.         return [
  31.             HeaderPageletLoadedEvent::class => 'onStorefrontLoaded'
  32.         ];
  33.     }
  34.     /**
  35.      * @param HeaderPageletLoadedEvent $event
  36.      */
  37.     public function onStorefrontLoaded(HeaderPageletLoadedEvent $event)
  38.     {
  39.         $cfg $this->systemConfig;
  40.         // icons
  41.         $customIcon1 $cfg->get('AutobatMarktThemePlugin.config.customIcon1');
  42.         $customIcon2 $cfg->get('AutobatMarktThemePlugin.config.customIcon2');
  43.         $customIcon3 $cfg->get('AutobatMarktThemePlugin.config.customIcon3');
  44.         $customIcon4 $cfg->get('AutobatMarktThemePlugin.config.customIcon4');
  45.         $customIcon5 $cfg->get('AutobatMarktThemePlugin.config.customIcon5');
  46.         // urls
  47.         $customUrl1 $cfg->get('AutobatMarktThemePlugin.config.customCatUrl1');
  48.         $customUrl2 $cfg->get('AutobatMarktThemePlugin.config.customCatUrl2');
  49.         $customUrl3 $cfg->get('AutobatMarktThemePlugin.config.customCatUrl3');
  50.         $customUrl4 $cfg->get('AutobatMarktThemePlugin.config.customCatUrl4');
  51.         $customUrl5 $cfg->get('AutobatMarktThemePlugin.config.customCatUrl5');
  52.         // well organized assigns
  53.         $pluginConfig = [
  54.             'catIcon1' => $customIcon1,
  55.             'catIcon2' => $customIcon2,
  56.             'catIcon3' => $customIcon3,
  57.             'catIcon4' => $customIcon4,
  58.             'catIcon5' => $customIcon5,
  59.             'catUrl1' => $customUrl1,
  60.             'catUrl2' => $customUrl2,
  61.             'catUrl3' => $customUrl3,
  62.             'catUrl4' => $customUrl4,
  63.             'catUrl5' => $customUrl5
  64.         ];
  65.         $event->getPagelet()->assign([self::CONFIG_NAMESPACE => $pluginConfig]);
  66.     }
  67. }