src/AutomarketBundle/Controller/MainController.php line 49

Open in your IDE?
  1. <?php
  2. namespace AutomarketBundle\Controller;
  3. use AutomarketBundle\Services\CatalogService;
  4. use AutomarketBundle\Services\MainService;
  5. use CoreBundle\Component\CoreFormFactory;
  6. use Doctrine\ORM\EntityManagerInterface;
  7. use Exception;
  8. use PortalBundle\Model\SeoMetaTag;
  9. use Symfony\Component\HttpFoundation\RedirectResponse;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\HttpFoundation\RequestStack;
  12. use Symfony\Component\HttpFoundation\Response;
  13. class MainController extends BaseController
  14. {
  15.     private CatalogService $catalogService;
  16.     private MainService $mainService;
  17.     public function __construct(CoreFormFactory $coreFormFactoryRequestStack $requestStackEntityManagerInterface $em,
  18.                                 SeoMetaTag      $seoMetaTagCatalogService $catalogServiceMainService $mainService)
  19.     {
  20.         parent::__construct($coreFormFactory$requestStack$em$seoMetaTag);
  21.         $this->catalogService $catalogService;
  22.         $this->mainService $mainService;
  23.     }
  24.     public function redirectAutomarket(): RedirectResponse
  25.     {
  26.         return $this->redirectToRoute('automarket_homepage');
  27.     }
  28.     public function index(Request $request): Response
  29.     {
  30.         $lang $request->getLocale();
  31.         $this->mainService->setLang($lang);
  32.         return $this->baseAutomarketRender('@Automarket/Main/index.html.twig', [
  33.             'onShowParam' => $this->catalogService->getOnShowFilter(),
  34.             'bodyTypes' => $this->mainService->getBodyTypes($this->getDealer()),
  35.             'newArrivals' => $this->mainService->getNewArrivals($this->getDealer(), $this->getUser(), true$lang),
  36.             'ourSelections' => $this->mainService->getOurSelections(),
  37.             'brands' => $this->mainService->getBrands($this->getDealer())
  38.         ]);
  39.     }
  40.     public function robots(): Response
  41.     {
  42.         $Dealer $this->getDealer();
  43.         $response = new Response();
  44.         $response->headers->set('Content-Type''text/plain');
  45.         return $this->baseAutomarketRender('@Automarket//robots.txt.twig', [
  46.             'Dealer' => $Dealer
  47.         ], $response);
  48.     }
  49.     public function pageError(Request $request): Response
  50.     {
  51.         return $this->baseAutomarketRender('@Automarket/404.html.twig', ['_locale' => $request->getLocale()]);
  52.     }
  53.     public function personalData(): Response
  54.     {
  55.         return $this->baseAutomarketRender('@Automarket/personal-data.html.twig', ['dealer' => $this->getDealer()]);
  56.     }
  57. }