src/Controller/IndexController.php line 30

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Kreno package.
  4.  *
  5.  * (c) Valentin Van Meeuwen <contact@wikub.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Controller;
  11. use App\Repository\CommitmentContractRepository;
  12. use App\Repository\CommitmentLogRepository;
  13. use App\Repository\JobRepository;
  14. use App\Repository\PostRepository;
  15. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  16. use Symfony\Component\HttpFoundation\Response;
  17. use Symfony\Component\Routing\Annotation\Route;
  18. /**
  19.  * @Route("/", name="index_")
  20.  */
  21. class IndexController extends AbstractController
  22. {
  23.     /**
  24.      * @Route("", name="index")
  25.      */
  26.     public function index(
  27.         JobRepository $jobRepository,
  28.         CommitmentContractRepository $commitmentContractRepository,
  29.         CommitmentLogRepository $commitmentLogRepository,
  30.         PostRepository $postRepository
  31.     ): Response {
  32.         // Get the next user jobs for next 45 days
  33.         $nextJobs $jobRepository->findNextForUser($this->getUser());
  34.         // Get the current user Contract
  35.         $currentCommitmentContract $commitmentContractRepository->getCurrentContractForUser($this->getUser());
  36.         // Get balance nb timeslot and hour
  37.         $sumNbTimeslot $commitmentLogRepository->getSumNbTimeslot($this->getUser());
  38.         $sumNbHour $commitmentLogRepository->getSumNbHour($this->getUser());
  39.         return $this->render('index/index.html.twig', [
  40.             'user' => $this->getUser(),
  41.             'nextJobs' => $nextJobs,
  42.             'currentCommitmentContract' => $currentCommitmentContract,
  43.             'sumNbTimeslot' => $sumNbTimeslot,
  44.             'sumNbHour' => $sumNbHour,
  45.             'posts' => $postRepository->findLastPublished(),
  46.         ]);
  47.     }
  48. }