src/DcSiteBundle/Controller/Suzuki/ServiceController.php line 80

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Suzuki;
  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\ServiceForm;
  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\RedirectResponse;
  19. use Symfony\Component\HttpFoundation\Request;
  20. use Symfony\Component\HttpFoundation\RequestStack;
  21. use Symfony\Component\HttpFoundation\Response;
  22. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  23. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  24. use Symfony\Component\Routing\RouterInterface;
  25. use Twig\Environment;
  26. class ServiceController extends BaseController
  27. {
  28.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStackRouterInterface $routerFormManager $formManagerEntityManagerInterface $emApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystemMediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactoryEnvironment $twig)
  29.     {
  30.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  31.     }
  32.     public function accessories(): RedirectResponse
  33.     {
  34.         return $this->redirect('https://shop.suzuki-vidi.com.ua/'Response::HTTP_MOVED_PERMANENTLY);
  35.     }
  36.     public function bodyRepair(): ?Response
  37.     {
  38.         $repairPhotoForm $this->CoreFormFactory()->repairPhotoForm();
  39.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/body-repair.html.twig', [
  40.             'repairPhotoForm' => $repairPhotoForm->createView(),
  41.         ]);
  42.     }
  43.     public function orderTo(): ?Response
  44.     {
  45.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/order-to.html.twig', [
  46.             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  47.             'dealerName' => $this->getDealer()->getBrand()->getName()
  48.         ]);
  49.     }
  50.     public function regulationsTo(VehicleService $vehicleService): ?Response
  51.     {
  52.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  53.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/regulations-to.html.twig', [
  54.             'models' => $models,
  55.         ]);
  56.     }
  57.     public function regulationsToModel($model): ?Response
  58.     {
  59.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  60.         if (!$model) {
  61.             throw new NotFoundHttpException();
  62.         }
  63.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/regulations-to-model.html.twig', [
  64.             'model' => $model->getId(),
  65.             'modelTitle' => $model->getTitle(),
  66.         ]);
  67.     }
  68.     public function parts(): ?Response
  69.     {
  70.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/parts.html.twig', [
  71.             'findPartForm' => $this->CoreFormFactory()->findPartForm($this->getDealer())->createView(),
  72.             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView(),
  73.             'sparesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Консультация по запасным частям'ViDiDepartmentModel::DEPARTMENT_TYPE_PARTSnull$this->getDealer())->createView(),
  74.         ]);
  75.     }
  76.     public function searchParts(Request $request): JsonResponse
  77.     {
  78.         $query $request->request->get('query');
  79.         $part $this->em->getRepository(Part::class)->findOneBy(['dealer' => $this->getDealer(), 'number' => $query]);
  80.         if (!$part) {
  81.             return new JsonResponse(['success' => false]);
  82.         }
  83.         return new JsonResponse([
  84.             'success' => true,
  85.             'data' => [
  86.                 'price' => $part->getPrice(),
  87.                 'id' => $part->getId(),
  88.                 'title' => $part->getNameByLocale($request->getLocale()),
  89.                 'art' => $part->getNumber(),
  90.                 'count' => $part->getCount(),
  91.             ]
  92.         ]);
  93.     }
  94.     public function warranty(): ?Response
  95.     {
  96.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/warranty.html.twig');
  97.     }
  98.     public function tiresHotel(): ?Response
  99.     {
  100.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/tires-hotel.html.twig', [
  101.             'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Шинний готель'nullnull$this->getDealer())->createView(),
  102.         ]);
  103.     }
  104.     public function holderProgram(): ?Response
  105.     {
  106.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/holder-program.html.twig');
  107.     }
  108.     public function extendedWarranty(): ?Response
  109.     {
  110.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/extended-warranty.html.twig', [
  111.             'servicesForm' => $this->CoreFormFactory()->fbDefQuestionForm('Интересует Продленная гарантия'nullnull$this->getDealer())->createView(),
  112.         ]);
  113.     }
  114.     public function multiConsultationEnter(): ?Response
  115.     {
  116.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation.html.twig');
  117.     }
  118.     public function multiConsultationForm(): ?Response
  119.     {
  120.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-form.html.twig');
  121.     }
  122.     public function multiConsultationFormOnline(): ?Response
  123.     {
  124.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-form-online.html.twig');
  125.     }
  126.     public function multiConsultationTestdriveForm(): ?Response
  127.     {
  128.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/consultation-testdrive-form.html.twig');
  129.     }
  130.     public function motoService(): ?Response
  131.     {
  132.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/moto-service.html.twig', [
  133.             'serviceForm' => $this->CoreFormFactory()->serviceForm(nullnullServiceForm::MOTO_SERVICE_TYPE1)->createView(),
  134.         ]);
  135.     }
  136.     public function nightServiceAgreement(): ?Response
  137.     {
  138.         return $this->baseSuzukiRender('@DcSite/Suzuki/Service/night-service-agreement.html.twig', [
  139.             'dealer' => $this->getDealer()
  140.         ]);
  141.     }
  142. }