src/Controller/HomeController.php line 28
<?phpnamespace App\Controller;use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;use Symfony\Component\Routing\Annotation\Route;use Symfony\Component\HttpFoundation\Response;use Doctrine\ORM\EntityManagerInterface;use App\Entity\MessageEntity;use App\Services\FlagsService;use Symfony\Contracts\Translation\TranslatorInterface;class HomeController extends AbstractController{private $flagsService;private $flags;private $translator;public function __construct(FlagsService $flagsService, TranslatorInterface $translator){$this->flagsService = $flagsService;$this->translator = $translator;}/*** @Route("/{_locale}/messages", name="home")*/public function home(EntityManagerInterface $entityManager): Response{$messages = $entityManager->getRepository(MessageEntity::class)->findBy(['user' => $this->getUser()], ['status' => 'ASC', 'id' => 'DESC']);if ($messages == null) {$this->addFlash('message', $this->translator->trans('no_messages_found'));$this->addFlash('color', 'secondary');}$this->flags = $this->flagsService->getflags();return $this->render('index.html.twig', ['messages' => $messages,'flags' => $this->flags,]);}/*** @Route("/{_locale}", name="index")*/public function index(EntityManagerInterface $entityManager): Response{$this->flags = $this->flagsService->getflags();return $this->render('home.html.twig', ['flags' => $this->flags,]);}/*** @Route("/", name="redirect_home")*/public function tohome(): Response{return $this->redirectToRoute('home', ['_locale' => 'en']);}}