custom/plugins/NetzpQuickBuy6/src/Subscriber/FrontendSubscriber.php line 37

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace NetzpQuickBuy6\Subscriber;
  3. use NetzpQuickBuy6\Components\QuickBuyHelper;
  4. use Shopware\Core\Framework\Struct\ArrayEntity;
  5. use Shopware\Core\System\SystemConfig\SystemConfigService;
  6. use Shopware\Storefront\Page\Account\Order\AccountOrderPageLoadedEvent;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\DependencyInjection\ContainerInterface;
  9. class FrontendSubscriber implements EventSubscriberInterface
  10. {
  11.     const SEARCH_TYPE_BLOG 10;
  12.     private $container;
  13.     private $config;
  14.     private $helper;
  15.     public function __construct(
  16.         ContainerInterface $container,
  17.         SystemConfigService $config,
  18.         QuickBuyHelper $helper)
  19.     {
  20.         $this->container $container;
  21.         $this->config $config;
  22.         $this->helper $helper;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             AccountOrderPageLoadedEvent::class => 'loadAccountOrderPage'
  28.         ];
  29.     }
  30.     public function loadAccountOrderPage(AccountOrderPageLoadedEvent $event): void
  31.     {
  32.         $page $event->getPage();
  33.         $orders $page->getOrders();
  34.         if($orders == null) {
  35.             return;
  36.         }
  37.         foreach ($orders as $order) {
  38.             $orderId $order->getId();
  39.             $documents $this->helper->getDocumentsForOrder($orderId$event->getSalesChannelContext());
  40.             $order->addExtension('netzpQuickBuyDocuments', new ArrayEntity(['documents' => $documents]));
  41.         }
  42.     }
  43. }