File tree Expand file tree Collapse file tree 3 files changed +39
-16
lines changed
Expand file tree Collapse file tree 3 files changed +39
-16
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,6 @@ public function __construct(private readonly EventRepository $eventRepository) {
1414
1515 public function __invoke (): Response
1616 {
17- //TODO : à supprimer quand les actions via le formulaire auront été migée
18- if (isset ($ _SESSION ['flash ' ]['message ' ])) {
19- $ this ->addFlash ('notice ' , $ _SESSION ['flash ' ]['message ' ]);
20- }
21- if (isset ($ _SESSION ['flash ' ]['erreur ' ])) {
22- $ this ->addFlash ('error ' , $ _SESSION ['flash ' ]['erreur ' ]);
23- }
24- unset($ _SESSION ['flash ' ]);
2517 $ list = $ this ->eventRepository ->getList ();
2618 return $ this ->render ('admin/event/list.html.twig ' , [
2719 'events ' => $ list ,
Original file line number Diff line number Diff line change @@ -76,14 +76,6 @@ public function backOffice()
7676 // Initialisation de AFUP_Log
7777 Logs::initialiser ($ bdd , $ droits ->obtenirIdentifiant ());
7878 require_once __DIR__ . '/../../../htdocs/pages/administration/ ' . $ _GET ['page ' ] . '.php ' ;
79- // On gère des infos popups
80- if (isset ($ _SESSION ['flash ' ]['message ' ])) {
81- $ this ->addFlash ('notice ' , $ _SESSION ['flash ' ]['message ' ]);
82- }
83- if (isset ($ _SESSION ['flash ' ]['erreur ' ])) {
84- $ this ->addFlash ('error ' , $ _SESSION ['flash ' ]['erreur ' ]);
85- }
86- unset($ _SESSION ['flash ' ]);
8779 // Récupération du contenu de la page généré par smarty
8880 $ content = $ smarty ->fetch ($ _GET ['page ' ] . '.html ' );
8981
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace AppBundle \Listener ;
6+
7+ use Symfony \Component \EventDispatcher \Attribute \AsEventListener ;
8+ use Symfony \Component \HttpFoundation \Exception \SessionNotFoundException ;
9+ use Symfony \Component \HttpFoundation \RequestStack ;
10+ use Symfony \Component \HttpFoundation \Session \FlashBagAwareSessionInterface ;
11+ use Symfony \Component \HttpKernel \KernelEvents ;
12+
13+ //TODO : à supprimer quand les flash messages du legacy seront migrés
14+ #[AsEventListener(KernelEvents::REQUEST )]
15+ final readonly class ConvertLegacyFlashMessageKernelListener
16+ {
17+ public function __construct (private RequestStack $ requestStack ) {}
18+
19+ public function onKernelRequest (): void
20+ {
21+ try {
22+ $ session = $ this ->requestStack ->getSession ();
23+ } catch (SessionNotFoundException ) {
24+ return ;
25+ }
26+
27+ if (!$ session instanceof FlashBagAwareSessionInterface) {
28+ return ;
29+ }
30+
31+ if (isset ($ _SESSION ['flash ' ]['message ' ])) {
32+ $ session ->getFlashBag ()->add ('notice ' , $ _SESSION ['flash ' ]['message ' ]);
33+ }
34+ if (isset ($ _SESSION ['flash ' ]['erreur ' ])) {
35+ $ session ->getFlashBag ()->add ('error ' , $ _SESSION ['flash ' ]['erreur ' ]);
36+ }
37+ unset($ _SESSION ['flash ' ]);
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments