custom/plugins/TemplaidInvoices/src/Controller/ListController.php line 52

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace TemplaidInvoices\Controller;
  3. use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  5. use Shopware\Core\Framework\Routing\Annotation\LoginRequired;
  6. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  7. use Shopware\Core\Framework\Routing\Annotation\Since;
  8. use Shopware\Core\Framework\Routing\Exception\MissingRequestParameterException;
  9. use Shopware\Core\Framework\Validation\DataBag\RequestDataBag;
  10. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  11. use Shopware\Storefront\Controller\StorefrontController;
  12. use Shopware\Storefront\Framework\Routing\Annotation\NoStore;
  13. use Symfony\Component\HttpFoundation\JsonResponse;
  14. use Symfony\Component\HttpFoundation\Request;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\HttpFoundation\Session\Session;
  17. use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener;
  18. use Symfony\Component\Routing\Annotation\Route;
  19. use TemplaidInvoices\Storefront\Page\Account\TemplaidAssortmentPageLoader;
  20. /**
  21.  * @RouteScope(scopes={"storefront"})
  22.  */
  23. class ListController extends StorefrontController
  24. {
  25.     private TemplaidAssortmentPageLoader $assortmentPageLoader;
  26.     public function __construct(
  27.         TemplaidAssortmentPageLoader $assortmentPageLoader
  28.     )
  29.     {
  30.         $this->assortmentPageLoader $assortmentPageLoader;
  31.     }
  32.     /**
  33.      * @Since("6.0.0.0")
  34.      * @LoginRequired()
  35.      * @Route("/account/assortment/{list}/{listId}", name="frontend.templaid.assortment.page", options={"seo"="false"}, methods={"GET", "POST"}, defaults={"XmlHttpRequest"=true})
  36.      * @NoStore()
  37.      *
  38.      * @throws CustomerNotLoggedInException
  39.      * @throws InconsistentCriteriaIdsException
  40.      * @throws MissingRequestParameterException
  41.      * @throws \Exception
  42.      */
  43.     public function invoices(string $liststring $listIdRequest $requestSalesChannelContext $context): Response
  44.     {
  45.         $page $this->assortmentPageLoader->load($request$context);
  46.         return $this->renderStorefront('@Storefront/storefront/page/account/assortment.html.twig', ['page' => $page'list' => $list'listId' => $listId]);
  47.     }
  48.     /**
  49.      * @Route("/templaid/listing/list-type", name="frontend.templaid.listing.listType", defaults={"csrf_protected"=false, "XmlHttpRequest"=true}, methods={"POST"})
  50.      */
  51.     public function setListType(Request $requestRequestDataBag $dataSalesChannelContext $context): JsonResponse
  52.     {
  53.         $request->getSession()->set('listType'$request->get('listType'));
  54.         return new JsonResponse(['success' => true]);
  55.     }
  56.     /**
  57.      * @Route("/templaid/listing/list-limit", name="frontend.templaid.listing.listLimit", defaults={"csrf_protected"=false, "XmlHttpRequest"=true}, methods={"POST"})
  58.      */
  59.     public function setListLimit(Request $requestRequestDataBag $dataSalesChannelContext $context): JsonResponse
  60.     {
  61.         $parameters $request->query->all();
  62.         $parameters['limit'] = (int)$request->get('listLimit');
  63.         $refRoute $request->get('refUrl');
  64.         return new JsonResponse(['success' => true'url' => $this->generateUrl($refRoute$parameters)]);
  65.     }
  66. }