src/Controller/OnlineOrder/Vendor/GetDishOptionsAction.php line 17

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Controller\OnlineOrder\Vendor;
  4. use Slivki\Controller\SiteController;
  5. use Slivki\Services\ImageService;
  6. use Slivki\Services\Offer\CustomProductOfferSorter;
  7. use Slivki\Services\Offer\OfferCacheService;
  8. use Slivki\Util\Iiko\AbstractDelivery;
  9. use Slivki\Util\Iiko\SushiVesla;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\HttpKernel\KernelInterface;
  12. use Symfony\Component\Routing\Annotation\Route;
  13. final class GetDishOptionsAction extends SiteController
  14. {
  15.     private ImageService $imageService;
  16.     private OfferCacheService $offerCacheService;
  17.     private CustomProductOfferSorter $customProductOfferSorter;
  18.     public function __construct(
  19.         ImageService $imageService,
  20.         OfferCacheService $offerCacheService,
  21.         CustomProductOfferSorter $customProductOfferSorter,
  22.         KernelInterface $kernel
  23.     ) {
  24.         parent::__construct($kernel);
  25.         $this->imageService $imageService;
  26.         $this->offerCacheService $offerCacheService;
  27.         $this->customProductOfferSorter $customProductOfferSorter;
  28.     }
  29.     /**
  30.      * @Route("/delivery/online-order/offer/{offerId}/dish-options",
  31.      *     name="delviery_online_order_offer_dish_options",
  32.      *     requirements={"offerId"="\d+"},
  33.      *     methods={"GET"}
  34.      * )
  35.      */
  36.     public function __invoke(int $offerId): Response
  37.     {
  38.         $offer $this->offerCacheService->getOffer($offerIdtruetrue);
  39.         $util AbstractDelivery::instance($offer);
  40.         $util->setContainer($this->kernel->getContainer());
  41.         $options $util instanceof SushiVesla
  42.             $util->getOptionsDB($this->imageService)
  43.             : $this->getOptions($this->imageService$offer$util0);
  44.         return $this->render('Slivki/delivery/dish/bill_dish_options.html.twig', [
  45.             'options' => $this->customProductOfferSorter->sort($optionsCustomProductOfferSorter::DEFAULT_CUSTOM_PRODUCT_SORT),
  46.         ]);
  47.     }
  48. }