src/PortalBundle/Controller/AboutController.php line 181

Open in your IDE?
  1. <?php
  2. namespace PortalBundle\Controller;
  3. use CoreBundle\Component\CoreFormFactory;
  4. use CoreBundle\Entity\Dealer;
  5. use CoreBundle\Entity\Post;
  6. use CoreBundle\Model\Vehicles\Repository;
  7. use CoreBundle\Services\MediaExtensionVidi;
  8. use DcSiteBundle\Entity\Vacancy;
  9. use Application\Sonata\MediaBundle\Entity\GalleryItem;
  10. use Doctrine\ORM\EntityManagerInterface;
  11. use PortalBundle\Services\OfferedVehicle;
  12. use PortalBundle\Entity\Blog;
  13. use PortalBundle\Entity\BlogCategory;
  14. use PortalBundle\Services\ServiceService;
  15. use Symfony\Component\HttpFoundation\Request;
  16. use Symfony\Component\HttpFoundation\RequestStack;
  17. use Symfony\Component\HttpFoundation\Response;
  18. use Symfony\Component\Routing\RouterInterface;
  19. class AboutController extends BaseController
  20. {
  21.     private MediaExtensionVidi $mediaExtensionVidi;
  22.     private OfferedVehicle $offeredVehicleService;
  23.     public function __construct(MediaExtensionVidi $mediaExtensionVidiOfferedVehicle $offeredVehicleService,
  24.                                 CoreFormFactory $coreFormFactoryRequestStack $requestStackRouterInterface $router,
  25.                                 Repository      $vehicleRepositoryServiceService $serviceService)
  26.     {
  27.         parent::__construct($coreFormFactory$requestStack$router$vehicleRepository$serviceService);
  28.         $this->mediaExtensionVidi $mediaExtensionVidi;
  29.         $this->offeredVehicleService $offeredVehicleService;
  30.     }
  31.     public function about(EntityManagerInterface $entityManager): Response
  32.     {
  33.         $dealers $entityManager->getRepository(Dealer::class)->getCarDealerOutputOrder();
  34.         foreach ($dealers as $dealer) {
  35.             $Brand $dealer->getBrand();
  36.             if (!$Brand or $Brand->getId() == 67) {
  37.                 continue;
  38.             }
  39.             if (isset($brands[$Brand->getId()])) {
  40.                 continue;
  41.             }
  42.             $brands[$Brand->getId()] = $Brand->getId();
  43.             $logos[] = [
  44.                 'image' => $Brand->getLogo(),
  45.                 'name' => $Brand->getName()
  46.             ];
  47.         }
  48.         return $this->basePortalRender('@Portal/About/about.html.twig', [
  49.             'logos' => $logos,
  50.             'dealers' => $dealers,
  51.         ]);
  52.     }
  53.     public function contactsSingle(Request $requestEntityManagerInterface $entityManager): Response
  54.     {
  55.         $locale $request->getLocale();
  56.         $seo_url $request->get('seo_url');
  57.         $dealer =$entityManager->getRepository(Dealer::class)->findOneBy(['seo_url' => $seo_url]);
  58.         if (!$dealer) {
  59.             throw $this->createNotFoundException();
  60.         }
  61.         $new =$entityManager->getRepository(Post::class)->getNewCarActionsByDealerId($dealer->getId(), 3);
  62.         $service =$entityManager->getRepository(Post::class)->getServiceActionsByDealerId($dealer->getId(), 3);
  63.         $gallery = [];
  64.         if ($dealer->getGallery() && $dealer->getGallery()->getGalleryItems()) {
  65.             /** @var GalleryItem $galleryItem */
  66.             foreach ($dealer->getGallery()->getGalleryItems() as $galleryItem) {
  67.                 $url $this->mediaExtensionVidi->getPath($galleryItem->getMedia(), 'reference');
  68.                 $gallery[] = $url;
  69.             }
  70.         }
  71.         $dealer = [
  72.             'id' => $dealer->getId(),
  73.             'name' => $dealer->getNameByLocale($locale),
  74.             'description' => $dealer->getDescriptionByLocale($locale),
  75.             'brandId' => $dealer->getBrand()->getId(),
  76.             'gallery' => $gallery,
  77.             'brandName' => $dealer->getBrand()->getName(),
  78.             'domain' => $dealer->getDomain(),
  79.             'url' => $dealer->getUrl(),
  80.             'cityId' => ($dealer->getCity()) ? $dealer->getCity()->getId() : null,
  81.             'cityName' => ($dealer->getCity()) ? $dealer->getCity()->getCityByLocale($locale) : null,
  82.             'logo' => $this->mediaExtensionVidi->getPath($dealer->getBrand()->getLogo(), 'reference'),
  83.             'img' => $this->mediaExtensionVidi->getPath($dealer->getImageServiceCenter(), 'reference'),
  84.             'address' => $dealer->getAddressByLocale($locale),
  85.             'phone' => $dealer->getPhone(),
  86.             'href_phone' => preg_replace('/[\s\(\)-]/'''$dealer->getPhone()),
  87.             'openTime' => $dealer->getOpenTime(),
  88.             'closeTime' => $dealer->getCloseTime(),
  89.             'mapUrl' => 'https://maps.google.com/maps?q=' $dealer->getLat() . ',' $dealer->getLng() . '&hl=' $locale,
  90.             'detail_url' => $dealer->getSeoUrl() ? $this->generateUrl('portal_contacts_single', ['seo_url' => $dealer->getSeoUrl()]) : '',
  91.             'brandUrl' => $dealer->getBrand()->getUrl(),
  92.         ];
  93.         return $this->basePortalRender('@Portal/Contacts/contacts-single.html.twig', [
  94.             'dealerByPage' => $dealer,
  95.             'actions' => [
  96.                 'new_car' => $new,
  97.                 'service' => $service,
  98.             ],
  99.             'newVehicles' => $this->offeredVehicleService->getLimitedUniqueModelByBrand($locale'new'$dealer['brandUrl']),
  100.             'usedVehicles' => $this->offeredVehicleService->getLimitedUniqueModelByBrand($locale'used'$dealer['brandUrl']),
  101.         ]);
  102.     }
  103.     public function qualityPolicy(): Response
  104.     {
  105.         return $this->basePortalRender('@Portal/About/quality-policy.html.twig');
  106.     }
  107.     public function information(): Response
  108.     {
  109.         return $this->basePortalRender('@Portal/About/information.html.twig');
  110.     }
  111.     public function informationPayment(): Response
  112.     {
  113.         return $this->basePortalRender('@Portal/About/payment.html.twig');
  114.     }
  115.     public function informationRules(): Response
  116.     {
  117.         return $this->basePortalRender('@Portal/About/rules.html.twig');
  118.     }
  119.     public function sharingRules(): Response
  120.     {
  121.         return $this->basePortalRender('@Portal/About/sharing.html.twig');
  122.     }
  123.     public function blog(Request $requestEntityManagerInterface $em): Response
  124.     {
  125.         $category $em->getRepository(BlogCategory::class)->findOneBy(['url' => $request->query->get('type')]);
  126.         $search $request->query->get('search');
  127.         $page $request->query->get('page'1);
  128.         $dealers $em->getRepository(Dealer::class)->getDealerWithPostsOnPortal();
  129.         return $this->basePortalrender('@Portal/About/blog/blog.html.twig',[
  130.             'dealers' => $dealers,
  131.             'category' => $category ? [
  132.                 'id' => $category->getId(),
  133.                 'url' => $category->getUrl(),
  134.                 'title' => $category->getTitle($request->getLocale()),
  135.             ] : null,
  136.             'search' => $search,
  137.             'page' => $page,
  138.         ]);
  139.     }
  140.     public function blogSingle(Request $requestEntityManagerInterface $em): Response
  141.     {
  142.         $post $em->getRepository(Blog::class)->findOneBy(['url' => $request->attributes->get('url')]);
  143.         $categoriesUrl = [];
  144.         foreach ($post->getCategories() as $category) {
  145.             $categoriesUrl[] = $category->getUrl();
  146.         }
  147.         $interestPosts $em->getRepository(Blog::class)->getBlogsFromOtherCategories($categoriesUrl3);
  148.         $similarPosts $em->getRepository(Blog::class)->getSimilarBlogs($post->getId(), $categoriesUrl3);
  149.         $post->setViews($post->getViews() + 1);
  150.         $em->flush();
  151.         $em->persist($post);
  152.         return $this->basePortalrender('@Portal/About/blog/blog-single.html.twig',[
  153.             'post' => $post,
  154.             'interestPosts' => $interestPosts,
  155.             'similarPosts' => $similarPosts
  156.         ]);
  157.     }
  158. //    Вакансии
  159.     public function vacancies(EntityManagerInterface $entityManager): Response
  160.     {
  161.         $vacancies $entityManager->getRepository(Vacancy::class)->findBy(['state' => true]);
  162.         return $this->basePortalRender('@Portal/About/vacancies.html.twig', ['vacancies' => $vacancies]);
  163.     }
  164.     //    Вакансии/Кар'єра
  165.     public function career(EntityManagerInterface $entityManager): Response
  166.     {
  167.         $dealers $entityManager->getRepository(Dealer::class)->findBy([], ['position' => 'ASC']);
  168.         $logos = [];
  169.         foreach ($dealers as $dealer) {
  170.             if (!$brand $dealer->getBrand()) {
  171.                 continue;
  172.             }
  173.             $logos[] = [
  174.                 'image' => $brand->getLogo(),
  175.                 'name' => $brand->getName(),
  176.             ];
  177.         }
  178.         return $this->basePortalRender('@Portal/About/career.html.twig', [
  179.             'logos' => $logos,
  180.         ]);
  181.     }
  182. //    Вакансии ID
  183.     public function singleVacancies($idEntityManagerInterface $entityManager): Response
  184.     {
  185.         $vacancyRepo $entityManager->getRepository(Vacancy::class);
  186.         $vacancy $vacancyRepo->find($id);
  187.         $relatedVacancies $vacancyRepo->findActiveLimitAndExcludeById($id);
  188.         $dealers $entityManager->getRepository(Dealer::class)->findBy([], ['position' => 'ASC']);
  189.         $logos = [];
  190.         foreach ($dealers as $dealer) {
  191.             if (!$brand $dealer->getBrand()) {
  192.                 continue;
  193.             }
  194.             $logos[] = [
  195.                 'image' => $brand->getLogo(),
  196.                 'name' => $brand->getName(),
  197.             ];
  198.         }
  199.         return $this->basePortalRender('@Portal/About/vacancies-id.html.twig', [
  200.             'vacancy' => $vacancy,
  201.             'logos' => $logos,
  202.             'relatedVacancies' => $relatedVacancies,
  203.             'vacancyForm' => $this->CoreFormFactory()->vacancyForm($vacancy->getDealer(), $vacancy)->createView()
  204.         ]);
  205.     }
  206.     public function privacyPolicy(): Response
  207.     {
  208.         return $this->basePortalRender('@Portal/About/privacy-policy.html.twig', []);
  209.     }
  210.     public function qualityService(): Response
  211.     {
  212.         return $this->basePortalRender('@Portal/About/quality-service.html.twig');
  213.     }
  214. }