custom/plugins/econdWebAnalytics/src/Storefront/Page/Account/Overview/Subscriber/AccountOverviewPageLoadedEventSubscriber.php line 20

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Ecd\econdWebAnalytics\Storefront\Page\Account\Overview\Subscriber;
  3. use ErrorException;
  4. use Shopware\Core\Framework\Struct\ArrayEntity;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Shopware\Storefront\Page\Account\Overview\AccountOverviewPageLoadedEvent;
  7. class AccountOverviewPageLoadedEventSubscriber implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             AccountOverviewPageLoadedEvent::class => 'onAccountOverviewPageLoadedEvent'
  13.         ];
  14.     }
  15.     public function onAccountOverviewPageLoadedEvent(AccountOverviewPageLoadedEvent $event)
  16.     {
  17.         $page $event->getPage();
  18.         $ana = [
  19.             'content' => strtok($_SERVER["REQUEST_URI"], '?'),
  20.             'pageId' => md5(strtok($_SERVER["REQUEST_URI"], '?'))
  21.         ];
  22.         try {
  23.             if ($_SESSION['emos_LogInRequestSend'] === true) {
  24.                 $ana['login_userid'] = $event->getSalesChannelContext()->getCustomer()->getCustomerNumber();
  25.                 unset($_SESSION['emos_LogInRequestSend']);
  26.             }
  27.         } catch (ErrorException $e) {
  28.             unset($ana['login_userid']);
  29.         }
  30.         try {
  31.             if ($_SESSION['emos_RegisterRequestSend'] === true) {
  32.                 $ana['register_userid'] = $event->getSalesChannelContext()->getCustomer()->getCustomerNumber();
  33.                 unset($_SESSION['emos_RegisterRequestSend']);
  34.             }
  35.         } catch (ErrorException $e) {
  36.             unset($ana['register_userid']);
  37.         }
  38.         $page->addExtension('ANA', new ArrayEntity($ana));
  39.     }
  40. }