src/Controller/SecurityController.php line 18

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Console\Application;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\Console\Input\ArrayInput;
  6. use Symfony\Component\Console\Output\BufferedOutput;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpKernel\KernelInterface;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
  11. class SecurityController extends AbstractController
  12. {
  13.     /* Route par défaut de l'app, sur le Login */
  14.     #[Route(path'/'name'app_login')]
  15.     public function login(AuthenticationUtils $authenticationUtils): Response
  16.     {
  17.         // if ($this->getUser()) {
  18.         //     return $this->redirectToRoute('target_path');
  19.         // }
  20.         // get the login error if there is one
  21.         $error $authenticationUtils->getLastAuthenticationError();
  22.         // last username entered by the user
  23.         $lastUsername $authenticationUtils->getLastUsername();
  24.         return $this->render('security/login.html.twig', ['last_username' => $lastUsername'error' => $error]);
  25.     }
  26.     /* Déconnexion du User */
  27.     #[Route(path'/logout'name'app_logout')]
  28.     public function logout(): void
  29.     {
  30.         throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
  31.     }
  32.     /* Route pour exécuter 'VerifDebutContratCommand', pour la tache CRON depuis Infomaniak */
  33.     #[Route(path'/commande/debut-contrat'name'commande-debut-contrat')]
  34.     public function commandeDebutContrat(KernelInterface $kernel): Response
  35.     {
  36.         /* Création d'une console avec kernel */
  37.         $application = new Application($kernel);
  38.         $application->setAutoExit(false);
  39.         /* Input de la console */
  40.         $input = new ArrayInput(['command' => 'verif-debut-contrat']);
  41.         /* Stockage de la sortie de la commande */
  42.         $output = new BufferedOutput();
  43.         /* Exécution de la commande */
  44.         $application->run($input$output);
  45.         /* Récupération de la sortie de la commande */
  46.         $content $output->fetch();
  47.         /* Sortie de la commande au format HTTP */
  48.         return new Response($content);
  49.     }
  50.     /* Route pour exécuter 'VerifFinContratCommand', pour la tache CRON depuis Infomaniak */
  51.     #[Route(path'/commande/fin-contrat'name'commande-fin-contrat')]
  52.     public function commandeFinContrat(KernelInterface $kernel): Response
  53.     {
  54.         /* Création d'une console avec kernel */
  55.         $application = new Application($kernel);
  56.         $application->setAutoExit(false);
  57.         /* Input de la console */
  58.         $input = new ArrayInput(['command' => 'verif-fin-contrat']);
  59.         /* Stockage de la sortie de la commande */
  60.         $output = new BufferedOutput();
  61.         /* Exécution de la commande */
  62.         $application->run($input$output);
  63.         /* Récupération de la sortie de la commande */
  64.         $content $output->fetch();
  65.         /* Sortie de la commande au format HTTP */
  66.         return new Response($content);
  67.     }
  68.     /* Route pour exécuter 'VerifRenouvellementContratCommand', pour la tache CRON depuis Infomaniak */
  69.     #[Route(path'/commande/renouvellement-contrat'name'commande-renouvellement-contrat')]
  70.     public function commandeRenouvellementContrat(KernelInterface $kernel): Response
  71.     {
  72.         /* Création d'une console avec kernel */
  73.         $application = new Application($kernel);
  74.         $application->setAutoExit(false);
  75.         /* Input de la console */
  76.         $input = new ArrayInput(['command' => 'verif-renouvellement-contrat']);
  77.         /* Stockage de la sortie de la commande */
  78.         $output = new BufferedOutput();
  79.         /* Exécution de la commande */
  80.         $application->run($input$output);
  81.         /* Récupération de la sortie de la commande */
  82.         $content $output->fetch();
  83.         /* Sortie de la commande au format HTTP */
  84.         return new Response($content);
  85.     }
  86.     /* Route pour exécuter 'MaintenanceContratCommand', pour la tache CRON depuis Infomaniak */
  87.     #[Route(path'/commande/maintenance-contrat'name'commande-maintenance-contrat')]
  88.     public function commandeMaintenanceContrat(KernelInterface $kernel): Response
  89.     {
  90.         /* Création d'une console avec kernel */
  91.         $application = new Application($kernel);
  92.         $application->setAutoExit(false);
  93.         /* Input de la console */
  94.         $input = new ArrayInput(['command' => 'maintenance-contrat']);
  95.         /* Stockage de la sortie de la commande */
  96.         $output = new BufferedOutput();
  97.         /* Exécution de la commande */
  98.         $application->run($input$output);
  99.         /* Récupération de la sortie de la commande */
  100.         $content $output->fetch();
  101.         /* Sortie de la commande au format HTTP */
  102.         return new Response($content);
  103.     }
  104. }