apps/pdi/src/Controller/HomeController.php line 34

  1. <?php
  2. namespace Pdi\Controller;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Pdi\Repository\ActionPlanObjectifRepository;
  5. use Pdi\Service\ModuleActionPlanManager;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Engine\Service\Interface\PdiInformationManagerInterface;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. use Symfony\Component\Security\Http\Attribute\CurrentUser;
  12. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  13. class HomeController extends AbstractController
  14. {
  15.     private ActionPlanObjectifRepository $actionPlanObjectifRepository;
  16.     private ModuleActionPlanManager $moduleActionPlanManager;
  17.     public function __construct(ActionPlanObjectifRepository $actionPlanObjectifRepositoryModuleActionPlanManager $moduleActionPlanManager)
  18.     {
  19.         $this->actionPlanObjectifRepository $actionPlanObjectifRepository;
  20.         $this->moduleActionPlanManager $moduleActionPlanManager;
  21.     }
  22.     /**
  23.      * @param Request $request
  24.      * @return Response
  25.      */
  26.     #[Route('/'name'user-homepage'methods: ['GET''POST'])]
  27.     public function UserHomePage(Request $request): Response
  28.     {
  29.         //Get connected user
  30.         $user $this->getUser();
  31.         $actionPlanObjectives $this->actionPlanObjectifRepository->findBy(['userId' => $user'status' => 1]);
  32.         $actionData $this->moduleActionPlanManager->associatedAllTaskToAction($actionPlanObjectives$user);
  33.         return $this->render(
  34.                       '@Pdi/page/home.html.twig',
  35.                       [
  36.                         'currentTasks' => $actionData,
  37.                       ]
  38.                   );
  39.     }
  40. }