src/Controller/DefaultController.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\NewsArticleRepository;
  4. use App\Services\UserService;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Routing\Annotation\Route;
  8. class DefaultController extends AbstractController
  9. {
  10.     /**
  11.      * @Route("/", name="index_route")
  12.      * @param NewsArticleRepository $newsArticleRepository
  13.      * @param UserService           $userService
  14.      * @return Response
  15.      */
  16.     public function indexAction(NewsArticleRepository $newsArticleRepositoryUserService $userService): Response
  17.     {
  18.         $user $this->getUser();
  19.         $latest3News $newsArticleRepository->findLatest3($user);
  20.         $isAdminUser $userService->getIsAdminUser($this->getUser());
  21.         return $this->render('default/index.html.twig', [
  22.             'environment' => $_ENV["APP_ENV"],
  23.             'latest_news' => $latest3News,
  24.             'isAdminUser' => $isAdminUser
  25.         ]);
  26.     }
  27. }