vendor/store.shopware.com/netinextmodal/src/Storefront/Controller/NetiModalController.php line 75

Open in your IDE?
  1. <?php
  2. /**
  3.  * @category NetiNextModal
  4.  * @author   bmueller
  5.  */
  6. namespace NetInventors\NetiNextModal\Storefront\Controller;
  7. use NetInventors\NetiNextModal\Services\ModalCriteriaBuilderInterface;
  8. use NetInventors\NetiNextModal\Services\ModalFilterServiceInterface;
  9. use NetInventors\NetiNextModal\Services\ModalServiceInterface;
  10. use NetInventors\NetiNextModal\Storefront\Controller\Traits\ContentBuilderTrait;
  11. use NetInventors\NetiNextModal\Storefront\Controller\Traits\CriteriaTrait;
  12. use NetInventors\NetiNextModal\Storefront\Controller\Traits\ResultTrait;
  13. use Shopware\Core\Content\Cms\SalesChannel\SalesChannelCmsPageLoaderInterface;
  14. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  15. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  16. use Shopware\Storefront\Controller\StorefrontController;
  17. use Symfony\Component\HttpFoundation\JsonResponse;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. /**
  21.  * @RouteScope(scopes={"storefront"})
  22.  */
  23. class NetiModalController extends StorefrontController
  24. {
  25.     use ContentBuilderTrait;
  26.     use CriteriaTrait;
  27.     use ResultTrait;
  28.     /**
  29.      * @var ModalServiceInterface
  30.      */
  31.     protected $modalService;
  32.     /**
  33.      * @var ModalFilterServiceInterface
  34.      */
  35.     protected $filterService;
  36.     /**
  37.      * NetiModalController constructor.
  38.      *
  39.      * @param ModalServiceInterface              $modalService
  40.      * @param ModalCriteriaBuilderInterface      $criteriaBuilder
  41.      * @param ModalFilterServiceInterface        $filterService
  42.      * @param SalesChannelCmsPageLoaderInterface $cmsPageLoader
  43.      */
  44.     public function __construct(
  45.         ModalServiceInterface $modalService,
  46.         ModalCriteriaBuilderInterface $criteriaBuilder,
  47.         ModalFilterServiceInterface $filterService,
  48.         SalesChannelCmsPageLoaderInterface $cmsPageLoader
  49.     ) {
  50.         $this->modalService    $modalService;
  51.         $this->criteriaBuilder $criteriaBuilder;
  52.         $this->filterService   $filterService;
  53.         $this->cmsPageLoader   $cmsPageLoader;
  54.     }
  55.     /**
  56.      * @Route(
  57.      *     "/neti_next_modal/get_box",
  58.      *     name="frontend.neti_next_modal.get_box",
  59.      *     options={"seo"="false"},
  60.      *     methods={"GET"},
  61.      *     defaults={"XmlHttpRequest"=true}
  62.      *     )
  63.      * @param Request             $request
  64.      * @param SalesChannelContext $salesChannelContext
  65.      *
  66.      * @return JsonResponse
  67.      */
  68.     public function getBox(Request $requestSalesChannelContext $salesChannelContext): JsonResponse
  69.     {
  70.         $context $salesChannelContext->getContext();
  71.         return $this->handleResult(
  72.             $request,
  73.             $salesChannelContext,
  74.             $this->filterService->filterModals(
  75.                 $this->modalService->findModals(
  76.                     $this->buildCriteria(
  77.                         $request
  78.                     ),
  79.                     $context
  80.                 ),
  81.                 $request,
  82.                 $context
  83.             )->last()
  84.         );
  85.     }
  86. }