custom/plugins/AcrisProductDownloadsCS/src/Storefront/Subscriber/CartSubscriber.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Acris\ProductDownloads\Storefront\Subscriber;
  3. use Acris\ProductDownloads\Components\ProductDownloadService;
  4. use Acris\ProductDownloads\Custom\ProductDownloadCollection;
  5. use Shopware\Core\Content\Product\Events\ProductGatewayCriteriaEvent;
  6. use Shopware\Core\System\SystemConfig\SystemConfigService;
  7. use Shopware\Storefront\Page\Product\ProductPageCriteriaEvent;
  8. use Shopware\Storefront\Page\Product\ProductPageLoadedEvent;
  9. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  10. class CartSubscriber implements EventSubscriberInterface
  11. {
  12.     private ProductDownloadService $productDownloadService;
  13.     private SystemConfigService $configService;
  14.     public function __construct(ProductDownloadService $productDownloadServiceSystemConfigService $configService)
  15.     {
  16.         $this->productDownloadService $productDownloadService;
  17.         $this->configService $configService;
  18.     }
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             ProductGatewayCriteriaEvent::class => 'onProductGatewayCriteria'
  23.         ];
  24.     }
  25.     public function onProductGatewayCriteria(ProductGatewayCriteriaEvent $event): void
  26.     {
  27.         $loadActive $this->configService->get('AcrisProductDownloadsCS.config.loadDataCheckout');
  28.         if(!empty($loadActive) && $loadActive === "load") {
  29.             $this->productDownloadService->addProductAssociationCriteria($event->getCriteria());
  30.         }
  31.         $linkLoadActive $this->configService->get('AcrisProductDownloadsCS.config.linkLoadDataCheckout');
  32.         if(!empty($linkLoadActive) && $linkLoadActive === "load") {
  33.             $this->productDownloadService->addProductLinkAssociationCriteria($event->getCriteria());
  34.         }
  35.     }
  36. }