custom/plugins/econdWebAnalytics/src/Storefront/Page/Checkout/Confirm/Subscriber/CheckoutConfirmPageLoadedEventSubscriber.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Ecd\econdWebAnalytics\Storefront\Page\Checkout\Confirm\Subscriber;
  3. use ErrorException;
  4. use Shopware\Core\Framework\Struct\ArrayEntity;
  5. use Shopware\Core\System\SystemConfig\SystemConfigService;
  6. use Shopware\Storefront\Page\Checkout\Confirm\CheckoutConfirmPageLoadedEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. class CheckoutConfirmPageLoadedEventSubscriber implements  EventSubscriberInterface
  9. {
  10.     private $systemConfigService;
  11.     public function __construct(SystemConfigService $systemConfigService)
  12.     {
  13.         $this->systemConfigService $systemConfigService;
  14.     }
  15.     /**
  16.      * @inheritDoc
  17.      */
  18.     public static function getSubscribedEvents()
  19.     {
  20.         return [
  21.             CheckoutConfirmPageLoadedEvent::class => 'onCheckoutConfirmPageLoadedEvent'
  22.         ];
  23.     }
  24.     public function onCheckoutConfirmPageLoadedEvent(CheckoutConfirmPageLoadedEvent $event)
  25.     {
  26.         $page $event->getPage();
  27.         $ana = [
  28.             'content' => strtok($_SERVER["REQUEST_URI"], '?'),
  29.             'pageId' => md5(strtok($_SERVER["REQUEST_URI"], '?'))
  30.         ];
  31.         try {
  32.             if ($_SESSION['emos_LogInRequestSend'] === true) {
  33.                 $ana['login_userid'] = md5($event->getSalesChannelContext()->getCustomer()->getEmail());
  34.                 unset($_SESSION['emos_LogInRequestSend']);
  35.             }
  36.         } catch (ErrorException $e) {
  37.             unset($ana['login_userid']);
  38.         }
  39.         try {
  40.             if ($_SESSION['emos_RegisterRequestSend'] === true) {
  41.                 $ana['register_userid'] = md5($event->getSalesChannelContext()->getCustomer()->getEmail());
  42.                 unset($_SESSION['emos_RegisterRequestSend']);
  43.             }
  44.         } catch (ErrorException $e) {
  45.             unset($ana['register_userid']);
  46.         }
  47.         $page->addExtension('ANA', new ArrayEntity($ana));
  48.     }
  49. }