src/Controller/MainController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\User;
  4. use App\Repository\PageRepository;
  5. use App\Service\StudentService;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class MainController extends AbstractController
  10. {
  11.     private StudentService $studentService;
  12.     private PageRepository $pageRepository;
  13.     public function __construct(StudentService $studentServicePageRepository $pageRepository)
  14.     {
  15.         $this->studentService $studentService;
  16.         $this->pageRepository $pageRepository;
  17.     }
  18.     /**
  19.      * @Route("/", name="main")
  20.      */
  21.     public function index(): Response
  22.     {
  23.         /** @var User $user */
  24.         $user $this->getUser();
  25.         if ($user) {
  26.             $courses $this->studentService->getInProgressCourses($user);
  27.             return $this->render('main/index_logged_in.html.twig', [
  28.                 'inProgressCourses' => $courses
  29.             ]);
  30.         }
  31.         $page $this->pageRepository->findOneByName('main');
  32.         return $this->render('main/index.html.twig', [
  33.             'content' => $page->getContent()
  34.         ]);
  35.     }
  36. }