src/DcSiteBundle/Controller/Citroen/AccessoriesController.php line 76

Open in your IDE?
  1. <?php
  2. namespace DcSiteBundle\Controller\Citroen;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Component\FormManager;
  5. use CoreBundle\Factory\Vehicle as VehicleFactory;
  6. use CoreBundle\Model\Api\OnlineService\ApiServer1C;
  7. use CoreBundle\Model\Vehicles\Repository;
  8. use CoreBundle\Services\MediaExtensionVidi;
  9. use DcSiteBundle\Services\AccessoryShopService;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use PortalBundle\Model\SeoMetaTag;
  12. use Symfony\Component\Filesystem\Filesystem;
  13. use Symfony\Component\HttpFoundation\RedirectResponse;
  14. use Symfony\Component\HttpFoundation\RequestStack;
  15. use Symfony\Component\HttpFoundation\Response;
  16. use Symfony\Component\DependencyInjection\ContainerInterface;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  19. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  20. use Symfony\Component\Routing\RouterInterface;
  21. use Twig\Environment;
  22. class AccessoriesController extends BaseController
  23. {
  24.     protected AccessoryShopService $accessoryShopService;
  25.     public function __construct(CoreFormFactory $coreFormFactorySeoMetaTag $seoMetaTagRequestStack $requestStack,
  26.                                 RouterInterface $routerFormManager $formManagerEntityManagerInterface $em,
  27.                                 ApiServer1C $apiServer1CSessionInterface $sessionFilesystem $filesystem,
  28.                                 MediaExtensionVidi $mediaExtensionVidiRepository $vehicleRepositoryVehicleFactory $vehicleFactory,
  29.                                 Environment $twigAccessoryShopService $accessoryShopService)
  30.     {
  31.         $this->accessoryShopService $accessoryShopService;
  32.         parent::__construct($coreFormFactory$seoMetaTag$requestStack$router$formManager$em$apiServer1C$session$filesystem$mediaExtensionVidi$vehicleRepository$vehicleFactory$twig);
  33.     }
  34.     public function accessoriesCatalog(): ?Response
  35.     {
  36.         $dealer $this->getDealer();
  37.         $accessoryCatalog $this->accessoryShopService->getAccessoryCatalog($dealer);
  38.         return $this->baseCitroenRender'@DcSiteBundle/Citroen/Accessories/accessories-catalog.html.twig'$accessoryCatalog);
  39.     }
  40.     public function accessoriesCategory(): ?Response
  41.     {
  42.         $dealer $this->getDealer();
  43.         $accessoryCategory $this->accessoryShopService->getAccessoryCategory($dealer);
  44.         if(!$accessoryCategory['accessoryCount']){
  45.             throw new NotFoundHttpException();
  46.         } else {
  47.             return $this->baseCitroenRender('@DcSite/Citroen/Accessories/accessories-catalog.html.twig'$accessoryCategory);
  48.         }
  49.     }
  50.     public function accessoriesModel(): ?Response
  51.     {
  52.         $dealer $this->getDealer();
  53.         $accessoryModel $this->accessoryShopService->getAccessoryModel($dealer);
  54.         return $this->baseCitroenRender('@DcSite/Citroen/Accessories/accessories-catalog.html.twig'$accessoryModel);
  55.     }
  56.     public function accessoriesModelVariation()
  57.     {
  58.         $dealer $this->getDealer();
  59.         $accessoryModel $this->accessoryShopService->getAccessoryModelAndVariation($dealer);
  60.         return $this->baseCitroenRender('@DcSite/Citroen/Accessories/accessories-catalog.html.twig'$accessoryModel);
  61.     }
  62.     public function accessoriesPage(Request $request): ?Response
  63.     {
  64.         $dealer $this->getDealer();
  65.         $accessoryPage $this->accessoryShopService->getAccessoryPage($dealer);
  66.         return $this->baseCitroenRender('@DcSite/Citroen/Accessories/accessories-page.html.twig'array_merge($accessoryPage, [
  67.             'domain' => 'https://' $request->getHost() . '/',
  68.         ]));
  69.     }
  70.     public function redirectToShop(ContainerInterface $container): RedirectResponse
  71.     {
  72.         return $this->redirect('https://' $container->getParameter('shop_citroen_host') . '/'Response::HTTP_MOVED_PERMANENTLY);
  73.     }
  74. }