custom/plugins/MoorlMerchantFinder/src/Storefront/Controller/MerchantController.php line 32

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Moorl\MerchantFinder\Storefront\Controller;
  3. use Moorl\MerchantFinder\Storefront\Page\Merchant\MerchantPageLoader;
  4. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  5. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  6. use Shopware\Storefront\Controller\StorefrontController;
  7. use Shopware\Storefront\Framework\Cache\Annotation\HttpCache;
  8. use Symfony\Component\HttpFoundation\JsonResponse;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. /**
  13.  * @Route(defaults={"_routeScope"={"storefront"}})
  14.  */
  15. class MerchantController extends StorefrontController
  16. {
  17.     private MerchantPageLoader $merchantPageLoader;
  18.     public function __construct(
  19.         MerchantPageLoader $merchantPageLoader
  20.     ) {
  21.         $this->merchantPageLoader $merchantPageLoader;
  22.     }
  23.     /**
  24.      * @HttpCache()
  25.      * @Route("/merchant/{merchantId}", name="moorl.merchant.detail", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  26.      */
  27.     public function detail(SalesChannelContext $contextRequest $request): Response
  28.     {
  29.         $page $this->merchantPageLoader->load($request$context);
  30.         if (!$page->getCmsPage()) {
  31.             return $this->renderStorefront('@Storefront/plugin/moorl-merchant-finder/page/merchant-detail/index.html.twig', [
  32.                 'page' => $page
  33.             ]);
  34.         }
  35.         return $this->renderStorefront('@Storefront/plugin/moorl-merchant-finder/page/content/merchant-detail.html.twig', [
  36.             'page' => $page
  37.         ]);
  38.     }
  39.     /**
  40.      * @Route("/merchant/{merchantId}/products", name="moorl.merchant.products", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  41.      */
  42.     public function products(SalesChannelContext $contextRequest $request): Response
  43.     {
  44.         $page $this->merchantPageLoader->load($request$context);
  45.         return $this->renderStorefront('@Storefront/storefront/element/cms-element-merchant-product-listing.html.twig', [
  46.             'page' => $page
  47.         ]);
  48.     }
  49.     /**
  50.      * @Route("/merchant/{merchantId}/filter", name="moorl.merchant.filter", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  51.      */
  52.     public function filter(SalesChannelContext $contextRequest $request): JsonResponse
  53.     {
  54.        return new JsonResponse([]);
  55.     }
  56. }