src/DcSiteBundle/Controller/Jaguar/ServiceController.php line 64

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Jaguar;
  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\Services\MediaExtensionVidi;
  10. use DcSiteBundle\Entity\Part;
  11. use DcSiteBundle\Model\Form\ServicesOrderForm;
  12. use DcSiteBundle\Services\VehicleService;
  13. use Doctrine\ORM\EntityManagerInterface;
  14. use PortalBundle\Model\SeoMetaTag;
  15. use Symfony\Component\Filesystem\Filesystem;
  16. use Symfony\Component\HttpFoundation\JsonResponse;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\RequestStack;
  19. use Symfony\Component\HttpFoundation\Response;
  20. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  21. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  22. use Symfony\Component\Routing\RouterInterface;
  23. use Twig\Environment;
  24. class ServiceController extends BaseController
  25. {
  26.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStackRouterInterface $routerFormManager $formManagerEntityManagerInterface $emApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystemMediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactoryEnvironment $twig)
  27.     {
  28.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  29.     }
  30.     public function accessories(): ?Response
  31.     {
  32.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/accessories.html.twig', [
  33.             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView(),
  34.         ]);
  35.     }
  36.     public function helpRoad(): ?Response
  37.     {
  38.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/help_road.html.twig');
  39.     }
  40.     public function orderTo(): ?Response
  41.     {
  42.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/order-to.html.twig', [
  43.             'serviceForm' => $this->CoreFormFactory()->serviceForm(nullnullnulltrue,$this->router->generate('jaguar_cokie'))->createView(),
  44.             'dealerName' => $this->getDealer()->getBrand()->getName(),
  45.             'isNight' => false
  46.         ]);
  47.     }
  48.     public function regulationsTo(VehicleService $vehicleService): ?Response
  49.     {
  50.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  51.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/regulations-to.html.twig', [
  52.             'models' => $models,
  53.         ]);
  54.     }
  55.     public function regulationsToModel($model): ?Response
  56.     {
  57.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  58.         if (!$model) {
  59.             throw new NotFoundHttpException();
  60.         }
  61.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/regulations-to-model.html.twig', [
  62.             'model' => $model->getId(),
  63.             'modelTitle' => $model->getTitle(),
  64.         ]);
  65.     }
  66.     public function warranty(): ?Response
  67.     {
  68.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/service_warranty.html.twig');
  69.     }
  70.     public function spareParts(): ?Response
  71.     {
  72.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/spare-parts.html.twig', [
  73.             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView()
  74.         ]);
  75.     }
  76.     public function calculationTo(): ?Response
  77.     {
  78.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/calculation_to.html.twig');
  79.     }
  80.     public function referenceMaterial(): ?Response
  81.     {
  82.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/reference-material.html.twig');
  83.     }
  84.     public function brandCollections(): ?Response
  85.     {
  86.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/brand-collections.html.twig');
  87.     }
  88.     public function searchParts(Request $request): JsonResponse
  89.     {
  90.         $query $request->request->get('query');
  91.         $part $this->em->getRepository(Part::class)->findOneBy(['dealer' => $this->getDealer(), 'number' => $query'state' => 1]);
  92.         if(!$part) {
  93.             return new JsonResponse(['success' => false]);
  94.         }
  95.         return new JsonResponse([
  96.             'success' => true,
  97.             'data' => [
  98.                 'price' => $part->getPrice(),
  99.                 'id' => $part->getId(),
  100.                 'title' => $part->getNameByLocale($request->getLocale()),
  101.                 'art' => $part->getNumber(),
  102.             ]
  103.         ]);
  104.     }
  105.     public function warrantyIncrease(): ?Response
  106.     {
  107.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/warranty-increase.html.twig');
  108.     }
  109.     public function replacementCar(): ?Response
  110.     {
  111.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/replacement-car.html.twig');
  112.     }
  113.     public function multiConsultationEnter(): ?Response
  114.     {
  115.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/consultation.html.twig');
  116.     }
  117.     public function multiConsultationForm(): ?Response
  118.     {
  119.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/consultation-form.html.twig');
  120.     }
  121.     public function multiConsultationFormOnline(): ?Response
  122.     {
  123.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/consultation-form-online.html.twig');
  124.     }
  125.     public function multiConsultationTestdriveForm(): ?Response
  126.     {
  127.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/consultation-testdrive-form.html.twig');
  128.     }
  129.     public function bodyRepair(): ?Response
  130.     {
  131.         $repairPhotoForm $this->CoreFormFactory()->repairPhotoForm();
  132.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/body-repair.html.twig',[
  133.             'repairPhotoForm' => $repairPhotoForm->createView(),
  134.         ]);
  135.     }
  136.     public function additionalServices(Request $request): ?Response
  137.     {
  138.         return $this->baseJaguarRender('@DcSite/Jaguar/Service/additional-services.html.twig', [
  139.             'mobileServiceForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::MOBILE_SERVICE$request->getLocale())->createView(),
  140.             'hotelForTiresForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::TIRE_HOTEL$request->getLocale())->createView(),
  141.             'antibacterialForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::ANTIBACTERIAL_SERVICE_CONDITIONER$request->getLocale())->createView(),
  142.             'washingRadiatorsForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::WASHING_COOLING_RADIATORS_SERVICE$request->getLocale())->createView(),
  143.             'finishingLeatherForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::FINISHING_LEATHER_OF_CAR_SERVICE$request->getLocale())->createView(),
  144.             'glueingProtectiveForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::GLUEING_CAR_PROTECTIVE_PELLICLE_SERVICE$request->getLocale())->createView(),
  145.             'toningCarForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::TONING_CAR_SERVICE$request->getLocale())->createView(),
  146.             'installationEngineProtectionForm' => $this->CoreFormFactory()->servicesOrderForm(ServicesOrderForm::INSTALLATION_ENGINE_PROTECTION_SERVICE$request->getLocale())->createView(),
  147.         ]);
  148.     }
  149. }