src/DcSiteBundle/Controller/Morris_Garage/ServiceController.php line 125

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Morris_Garage;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Component\FormManager;
  5. use CoreBundle\Entity\Dealer;
  6. use CoreBundle\Entity\Model;
  7. use CoreBundle\Factory\Vehicle as VehicleFactory;
  8. use CoreBundle\Model\Api\OnlineService\ApiServer1C;
  9. use CoreBundle\Model\Vehicles\Repository;
  10. use CoreBundle\Services\MediaExtensionVidi;
  11. use DcSiteBundle\Entity\Part;
  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\RedirectResponse;
  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 orderTo(): ?Response
  32.     {
  33.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/order-to.html.twig', [
  34.             'serviceForm' => $this->CoreFormFactory()->serviceForm()->createView(),
  35.             'dealerName' => $this->getDealer()->getBrand()->getName()
  36.         ]);
  37.     }
  38.     public function accessories(): RedirectResponse
  39.     {
  40.         return $this->redirect('https://shop.mg-vidi.com.ua');
  41.     }
  42.     public function spareParts(): ?Response
  43.     {
  44.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/spare-parts.html.twig', [
  45.             'buyPartsForm' => $this->CoreFormFactory()->buyPartsForm($this->getDealer())->createView()
  46.         ]);
  47.     }
  48.     public function searchParts(Request $request): JsonResponse
  49.     {
  50.         $query $request->request->get('query');
  51.         $Dealer $this->em->getRepository(Dealer::class)->find(37);
  52.         $part $this->em->getRepository(Part::class)->findOneBy(['dealer' => $Dealer'number' => $query]);
  53.         if (!$part) {
  54.             return new JsonResponse(['success' => false]);
  55.         }
  56.         return new JsonResponse([
  57.             'success' => true,
  58.             'data' => [
  59.                 'price' => $part->getPrice(),
  60.                 'id' => $part->getId(),
  61.                 'title' => $part->getNameByLocale($request->getLocale()),
  62.                 'art' => $part->getNumber(),
  63.             ]
  64.         ]);
  65.     }
  66.     public function bodyRepair(): ?Response
  67.     {
  68.         $repairPhotoForm $this->CoreFormFactory()->repairPhotoForm();
  69.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/body-repair.html.twig', [
  70.             'repairPhotoForm' => $repairPhotoForm->createView(),
  71.         ]);
  72.     }
  73.     public function regulationsTo(VehicleService $vehicleService): ?Response
  74.     {
  75.         $models $vehicleService->getModelsForRegulationsTo($this->getDealer());
  76.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/regulations-to.html.twig', [
  77.             'models' => $models,
  78.         ]);
  79.     }
  80.     public function regulationsToModel($model): ?Response
  81.     {
  82.         $model $this->em->getRepository(Model::class)->findOneBy(['url' => $model]);
  83.         if (!$model) {
  84.             throw new NotFoundHttpException();
  85.         }
  86.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/regulations-to-model.html.twig', [
  87.             'model' => $model->getId(),
  88.             'modelTitle' => $model->getTitle(),
  89.         ]);
  90.     }
  91.     public function multiConsultationEnter(): ?Response
  92.     {
  93.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/consultation.html.twig');
  94.     }
  95.     public function multiConsultationForm(): ?Response
  96.     {
  97.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/consultation-form.html.twig');
  98.     }
  99.     public function multiConsultationFormOnline(): ?Response
  100.     {
  101.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/consultation-form-online.html.twig');
  102.     }
  103.     public function multiConsultationTestdriveForm(): ?Response
  104.     {
  105.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/consultation-testdrive-form.html.twig');
  106.     }
  107.     public function manuals(): ?Response
  108.     {
  109.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/manuals.html.twig');
  110.     }
  111.     public function nightServiceAgreement(): ?Response
  112.     {
  113.         return $this->baseMorrisGarageRender('@DcSite/Morris_Garage/Service/night-service-agreement.html.twig', [
  114.             'dealer' => $this->getDealer()
  115.         ]);
  116.     }
  117. }