<?php
namespace App\Controller;
use App\Repository\NewsArticleRepository;
use App\Services\UserService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends AbstractController
{
/**
* @Route("/", name="index_route")
* @param NewsArticleRepository $newsArticleRepository
* @param UserService $userService
* @return Response
*/
public function indexAction(NewsArticleRepository $newsArticleRepository, UserService $userService): Response
{
$user = $this->getUser();
$latest3News = $newsArticleRepository->findLatest3($user);
$isAdminUser = $userService->getIsAdminUser($this->getUser());
return $this->render('default/index.html.twig', [
'environment' => $_ENV["APP_ENV"],
'latest_news' => $latest3News,
'isAdminUser' => $isAdminUser
]);
}
}