src/Controller/MainController.php line 46

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\AboutRepository;
  4. use App\Repository\HeaderRepository;
  5. use App\Repository\LangAreaRepository;
  6. use App\Repository\SectionTitleRepository;
  7. use App\Repository\ServicesRepository;
  8. use App\Repository\TeamsRepository;
  9. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. class MainController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/{_locale<%app.supported_locales%>}/", name="app_main")
  16.      */
  17.     public function index(HeaderRepository $headerRepository, SectionTitleRepository $titleRepository,
  18.                           LangAreaRepository $areaRepository, AboutRepository $aboutRepository, TeamsRepository $teamsRepository, ServicesRepository $servicesRepository): Response
  19.     {
  20.         $header = $headerRepository->findByIsActive(1);
  21.         $lang = $areaRepository->findByIsActive(1);
  22.         $team = $teamsRepository->findByIsActive(1);
  23.         $about = $aboutRepository->findAboutPostByTag('about_index');
  24.         $service = $titleRepository->findTitleByTag('services_home');
  25.         $service = $titleRepository->findTitleByTag('services_home');
  26.         $homeservices = $servicesRepository->findByIsHome(1);
  27.         $traduction = $servicesRepository->findServicesByTag('tradcution_index');
  28.         return $this->render('main/index.html.twig', [
  29.             'headers' => $header,
  30.             'langs' => $lang,
  31.             'abouts' => $about,
  32.             'teams' => $team,
  33.             'servicesTitle' => $service,
  34.             'services' => $homeservices,
  35.             'translation' => $traduction
  36.         ]);
  37.     }
  38.     /**
  39.      * @Route("/")
  40.      */
  41.     public function indexNoLocal(): Response
  42.     {
  43.         return $this->redirectToRoute('app_main', ['_locale' => 'fr']);
  44.     }
  45. }