src/Controller/Beauty/GetMasterAction.php line 16

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Slivki\Controller\Beauty;
  4. use Slivki\Repository\Beauty\Masters\BeautyMasterRepositoryInterface;
  5. use Slivki\Response\Beauty\Offer\Factory\MasterResponseFactory;
  6. use Slivki\Services\CategoryBoxCacheService;
  7. use Slivki\Services\DeviceTypeService;
  8. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. final class GetMasterAction extends AbstractController
  13. {
  14.     private MasterResponseFactory $masterResponseFactory;
  15.     private BeautyMasterRepositoryInterface $beautyMasterRepository;
  16.     private CategoryBoxCacheService $categoryBoxCacheService;
  17.     private DeviceTypeService $deviceTypeService;
  18.     public function __construct(
  19.         BeautyMasterRepositoryInterface $beautyMasterRepository,
  20.         MasterResponseFactory $masterResponseFactory,
  21.         CategoryBoxCacheService $categoryBoxCacheService,
  22.         DeviceTypeService $deviceTypeService
  23.     ) {
  24.         $this->masterResponseFactory $masterResponseFactory;
  25.         $this->beautyMasterRepository $beautyMasterRepository;
  26.         $this->categoryBoxCacheService $categoryBoxCacheService;
  27.         $this->deviceTypeService $deviceTypeService;
  28.     }
  29.     /**
  30.      * @Route("/offer/master/{masterId}", name="offer_master_get", methods={"GET"})
  31.      */
  32.     public function __invoke(Request $requestint $masterId): Response
  33.     {
  34.         $master $this->masterResponseFactory->create(
  35.             $this->beautyMasterRepository->getById($masterId),
  36.         );
  37.         $view $this->deviceTypeService->isMobileDevice($request)
  38.             ? 'Slivki/mobile/beauty/master.html.twig'
  39.             'Slivki/beauty/offer/master.html.twig';
  40.         return $this->render($view, [
  41.             'master' => $master,
  42.             'offers' => $this->categoryBoxCacheService->getCategoryBoxByOfferIDList(
  43.                 $master->getOfferIds(),
  44.                 $this->deviceTypeService->isMobileDevice($request),
  45.             ),
  46.         ]);
  47.     }
  48. }