src/Controller/Front/MainController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Front;
  3. use Stimactiv\CmsBundle\Repository\PageI18nRepository;
  4. use Stimactiv\CoreBundle\Repository\LangRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * @Route("/", name="frontend_")
  11.  */
  12. class MainController extends AbstractController implements AgeVerificationControllerInterface
  13. {
  14.     /**
  15.      * @Route("/", name="home", methods={"GET"})
  16.      */
  17.     public function index(Request $requestLangRepository $langRepositoryPageI18nRepository $pageI18nRepository): Response
  18.     {
  19.         $lang $langRepository->findOneBy(['code' => $request->getLocale()]);
  20.         if ($lang === null) {
  21.             $lang $langRepository->findOneBy(['byDefault' => true]);
  22.         }
  23.         $page_id 1// TODO
  24.         $pageI18n $pageI18nRepository->findOneBy(['page' => $page_id'lang' => $lang]);
  25.         if ($pageI18n === null) {
  26.             throw $this->createNotFoundException();
  27.         }
  28.         return $this->redirectToRoute('frontend_page_show', ['slug' => $pageI18n->getSlug()]);
  29.     }
  30. }