src/DcSiteBundle/Controller/Lexus/ServiceController.php line 142

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Lexus;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Component\FormManager;
  5. use CoreBundle\Entity\Model;
  6. use CoreBundle\Factory\Vehicle as VehicleFactory;
  7. use CoreBundle\Model\Api\OnlineService\ApiServer1C;
  8. use CoreBundle\Model\Vehicles\Repository;
  9. use CoreBundle\Model\ViDiDepartmentModel;
  10. use CoreBundle\Services\MediaExtensionVidi;
  11. use DcSiteBundle\Entity\Part;
  12. use DcSiteBundle\Model\Form\ServicesOrderForm;
  13. use DcSiteBundle\Services\VehicleService;
  14. use Doctrine\ORM\EntityManagerInterface;
  15. use PortalBundle\Model\SeoMetaTag;
  16. use Symfony\Component\Filesystem\Filesystem;
  17. use Symfony\Component\HttpFoundation\JsonResponse;
  18. use Symfony\Component\HttpFoundation\Request;
  19. use Symfony\Component\HttpFoundation\RequestStack;
  20. use Symfony\Component\HttpFoundation\Response;
  21. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  22. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  23. use Symfony\Component\Routing\RouterInterface;
  24. use Twig\Environment;
  25. class ServiceController extends BaseController
  26. {
  27.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStackRouterInterface $routerFormManager $formManagerEntityManagerInterface $emApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystemMediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactoryEnvironment $twig)
  28.     {
  29.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  30.     }
  31.     public function assistance(): ?Response
  32.     {
  33.         return $this->baseLexusRender('@DcSite/Lexus/Service/assistance.html.twig');
  34.     }
  35.     public function bodyRepair(): ?Response
  36.     {
  37.         $repairPhotoForm $this->CoreFormFactory()->repairPhotoForm();
  38.         return $this->baseLexusRender('@DcSite/Lexus/Service/body-repair.html.twig', [
  39.             'repairPhotoForm' => $repairPhotoForm->createView(),
  40.         ]);
  41.     }
  42.     public function priceForCar(VehicleService $vehicleService): ?Response
  43.     {
  44.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  45.         return $this->baseLexusRender('@DcSite/Lexus/Service/price-for-car.html.twig', [
  46.             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  47.             'models' => $models,
  48.             'brand' => $this->getDealer()->getBrand()->getName(),
  49.         ]);
  50.     }
  51.     public function priceFormCarModel($model): ?Response
  52.     {
  53.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  54.         if (!$model) {
  55.             throw new NotFoundHttpException();
  56.         }
  57.         return $this->baseLexusRender('@DcSite/Lexus/Service/price-for-car-model.html.twig', [
  58.             'model' => $model->getId(),
  59.             'modelTitle' => $model->getTitle(),
  60.         ]);
  61.     }
  62.     public function spareParts(): ?Response
  63.     {
  64.         return $this->baseLexusRender('@DcSite/Lexus/Service/spare-parts.html.twig', [
  65.             'feedbackForm' => $this->CoreFormFactory()->fbDefQuestionForm('Запрос консультации о выкупе авто'ViDiDepartmentModel::DEPARTMENT_TYPE_PARTSnull$this->getDealer())->createView(),
  66. //            'buyPartsForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  67.             'spareForm' => $this->CoreFormFactory()->buySparePartsForm($this->getDealer())->createView(),
  68.         ]);
  69.     }
  70.     public function searchPart(Request $request): JsonResponse
  71.     {
  72.         $search $request->request->get('searchString');
  73.         $part $this->em->getRepository(Part::class)->findOneBy(['dealer' => $this->getDealer(), 'number' => $search]);
  74.         if (!$part) {
  75.             return new JsonResponse(['success' => false]);
  76.         }
  77.         return new JsonResponse(['success' => true'data' => [
  78.             'isInStock' => $part->getCount() > 0,
  79.             'price' => $part->getPrice(),
  80.             'id' => $part->getId(),
  81.             'title' => $part->getNameByLocale($request->getLocale()),
  82.         ]]);
  83.     }
  84.     public function tireHotel(Request $request): ?Response
  85.     {
  86.         return $this->baseLexusRender('@DcSite/Lexus/Service/tire-hotel.html.twig', [
  87.             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::TIRE_HOTEL$request->getLocale())->createView(),
  88.         ]);
  89.     }
  90.     public function detailing(Request $request): ?Response
  91.     {
  92.         return $this->baseLexusRender('@DcSite/Lexus/Service/detailing.html.twig', [
  93.             'serviceOrderForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::TIRE_HOTEL$request->getLocale())->createView(),
  94.         ]);
  95.     }
  96.     public function luggageBoxes(Request $request): ?Response
  97.     {
  98.         $rental $this->vehicleRepository->getRentalByDealer($this->getDealer());
  99.         $result = [];
  100.         foreach ($rental as $item) {
  101.             $model $this->vehicleFactory->createByVehicleItem($item);
  102.             if ($model) {
  103.                 $result[] = $model;
  104.             }
  105.         }
  106.         return $this->baseLexusRender('@DcSite/Lexus/Service/luggage-boxes.html.twig', [
  107.             'rentForm' => $this->CoreFormFactory()->rentLuggageForm($this->getDealer())->createView(),
  108.             'rentalCars' => $result,
  109.         ]);
  110.     }
  111.     public function orderto(): ?Response
  112.     {
  113.         $serviceForm $this->CoreFormFactory()->serviceForm();
  114.         return $this->baseLexusRender('@DcSite/Lexus/Service/order-to.html.twig', [
  115.             'serviceForm' => $serviceForm->createView(),
  116.             'dealerName' => $this->getDealer()->getBrand()->getName()
  117.         ]);
  118.     }
  119.     public function multiConsultationEnter(): ?Response
  120.     {
  121.         return $this->baseLexusRender('@DcSite/Lexus/Service/consultation.html.twig');
  122.     }
  123.     public function multiConsultationForm(): ?Response
  124.     {
  125.         return $this->baseLexusRender('@DcSite/Lexus/Service/consultation-form.html.twig');
  126.     }
  127.     public function multiConsultationFormOnline(): ?Response
  128.     {
  129.         return $this->baseLexusRender('@DcSite/Lexus/Service/consultation-form-online.html.twig');
  130.     }
  131.     public function multiConsultationTestdriveForm(): ?Response
  132.     {
  133.         return $this->baseLexusRender('@DcSite/Lexus/Service/consultation-testdrive-form.html.twig');
  134.     }
  135.     public function signalLamps(): ?Response
  136.     {
  137.         return $this->baseLexusRender('@DcSite/Lexus/Service/signal-lamps.html.twig');
  138.     }
  139.     public function extendedWarranty(): ?Response
  140.     {
  141.         return $this->baseLexusRender('@DcSite/Lexus/Service/extended-warranty.html.twig');
  142.     }
  143.     public function mobilityOptions(): ?Response
  144.     {
  145.         return $this->baseLexusRender('@DcSite/Lexus/Service/mobility-options.html.twig');
  146.     }
  147.     public function nightServiceAgreement(): ?Response
  148.     {
  149.         return $this->baseLexusRender('@DcSite/Lexus/Service/night-service-agreement.html.twig', [
  150.             'dealer' => $this->getDealer()
  151.         ]);
  152.     }
  153. }