custom/plugins/VerignFeedback/src/Storefront/Subscriber/FeedbackSubscriber.php line 51

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Verign\VerignFeedback\Storefront\Subscriber;
  3. use Verign\VerignFeedback\Components\StorefrontFitter;
  4. use Shopware\Core\System\SystemConfig\SystemConfigService;
  5. use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
  6. use Shopware\Storefront\Event\ThemeCompilerEnrichScssVariablesEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Verign\VerignFeedback\Components\FeedbackCaptcha;
  9. class FeedbackSubscriber implements EventSubscriberInterface {
  10.     private $systemConfigService;
  11.     /**
  12.      * @var FeedbackCaptcha
  13.      */
  14.     private $fCaptcha;
  15.     public function __construct(SystemConfigService $systemConfigServiceFeedbackCaptcha $fCaptcha)
  16.     {
  17.         $this->systemConfigService $systemConfigService;
  18.         $this->fCaptcha $fCaptcha;
  19.     }
  20.     public static function getSubscribedEvents() : array
  21.     {
  22.         return[
  23.             HeaderPageletLoadedEvent::class => 'addConfigInformations',
  24.             ThemeCompilerEnrichScssVariablesEvent::class => 'addScssVariables'
  25.         ];
  26.     }
  27.     public function addConfigInformations(HeaderPageletLoadedEvent $event) {
  28.         $config $this->systemConfigService->get('VerignFeedback.config',
  29.             $event->getSalesChannelContext()->getSalesChannel()->getId());
  30.         if(key_exists('isActivated'$config) && $config['isActivated'] === true){
  31.             $sf = new StorefrontFitter();
  32.             //die(var_dump($config));
  33.             if(key_exists('hasCaptcha'$config) && $config['hasCaptcha'] === true){
  34.                 $config['imgBase64'] = $this->fCaptcha->generateCaptcha();
  35.             }
  36.             $sf->setArray($config);
  37.             $event->getPagelet()->addExtension("vfeedbackConfig"$sf);
  38.         }
  39.     }
  40.     public function addScssVariables(ThemeCompilerEnrichScssVariablesEvent $event){
  41.         // Will render: $sass-plugin-name-color: #ffcc59;
  42.         $event->addVariable('sass-plugin-name-color''#ffcc59');
  43.     }
  44. }