src/Controller/PortalConsejoController.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use App\Service\PortalConsejoService;
  7. use App\Form\PersonaType;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use App\Entity\SsoSistema;
  10. use App\Repository\SsoSistemaRepository;
  11. use App\Entity\Auditoria\Registro;
  12. use App\Repository\Escuela\EgresadoRepository;
  13. use App\Service\AuditoriaService;
  14. #[Route('/portal/consejo')]
  15. class PortalConsejoController extends AbstractController
  16. {
  17.     #[Route('/'name'portal_consejo')]
  18.     public function index(SsoSistemaRepository $sistemaRepository): Response
  19.     {
  20.         // Tomo los sistemas asignados al usuario y que se encuentren activos
  21.         $sistemas $this->getUser()->getSsoUsuarioSistemas()->map(
  22.             function ($relacion) {
  23.                 return $relacion->getSistema();
  24.             })->filter(
  25.                 function ($sistema) {
  26.                     return $sistema->getClienteOauth2()->isActive();
  27.                 });
  28.         return $this->render('portal_consejo/index.html.twig', [
  29.             'sistemas' => $sistemas,
  30.         ]);
  31.     }
  32.     #[Route('/{id}/sistema'name'portal_ir_sistema')]
  33.     public function irSistema(
  34.         Request $request,
  35.         SsoSistema $sistema,
  36.         AuditoriaService $auditoriaService,
  37.         EgresadoRepository $egresadoRepository
  38.     ): Response
  39.     {
  40.         // Validar si es egresado en el caso de seleccionar ria
  41.         // if ($sistema->getClienteOauth2()->getIdentifier() == 'ria_consejo') {
  42.         //     $egresado = $egresadoRepository->findEgresadoByDNI(
  43.         //         $this->getUser()->getPersona()->getDni()
  44.         //     );
  45.         //     if ($this->getUser()->getPersona()->getDni() <> 30281944) {
  46.         //         if (!$egresado) {
  47.         //             $request->getSession()->getFlashBag()->add(
  48.         //                 'error', // notice / warning / error
  49.         //                 'Para ingresar al RIA debe ser Egresado de la Escuela Judicial.'
  50.         //             );
  51.         //             return $this->redirectToRoute('portal_aspirante', [], 
  52.         //                 Response::HTTP_SEE_OTHER);
  53.         //         }
  54.         //     }
  55.         // }
  56.         $auditoriaService->auditarEvento(Registro::EVENTO_MODULO_INGRESOnull$sistema);
  57.         $url $sistema->getUrl();
  58.         return $this->redirect($urlResponse::HTTP_SEE_OTHER);
  59.     }
  60.     #[Route('/perfil'name'perfil')]
  61.     public function perfil(Request $request
  62.         PortalConsejoService $portalService): Response
  63.     {
  64.         $form $this->createForm(
  65.             PersonaType::class, 
  66.             $this->getUser()->getPersona(),
  67.             ['disabled' => true]
  68.         );
  69.         $formPassword $portalService->procesarCambioPassword($request$this->getUser());
  70.         $formEmail $portalService->procesarCambioEmail($request$this->getUser());
  71.         
  72.         return $this->renderForm('portal_consejo/perfil.html.twig', [
  73.             'form' => $form,
  74.             'formPassword' => $formPassword,
  75.             'formEmail' => $formEmail,
  76.         ]);
  77.     }
  78.     #[Route('/conf_correo/{mail}/{token}'name'confirma_correo')]
  79.     public function confirmaCorreo(
  80.         Request $request
  81.         PortalConsejoService $portalService,
  82.         String $mail
  83.         String $token): Response
  84.     {
  85.         $portalService->procesarConfirmacionCambioEmail($request$mail$token);
  86.         if (in_array('ROLE_CONSEJO'$this->getUser()->getRoles()))
  87.             return $this->redirectToRoute('perfil', [
  88.                 // 'id' => $ultimaSesion->getId(),
  89.             ], Response::HTTP_SEE_OTHER);
  90.         else
  91.             return $this->redirectToRoute('portal_aspirante_perfil', [
  92.                 // 'id' => $ultimaSesion->getId(),
  93.             ], Response::HTTP_SEE_OTHER);
  94.     }
  95.     #[Route('/help'name'ayuda')]
  96.     public function ayuda(): Response
  97.     {
  98.         return $this->render('portal_consejo/index.html.twig', [
  99.             'controller_name' => 'PortalConsejoController',
  100.         ]);
  101.     }
  102. }