@@ -46,14 +46,14 @@ final class ImportDataAction
4646 public function __construct (
4747 ImportProcessorInterface $ importProcessor ,
4848 FormFactoryInterface $ formFactory ,
49- FlashBagInterface $ flashBag ,
49+ RequestStack $ requestStack ,
5050 FormErrorsFlashHelperInterface $ formErrorsFlashHelper ,
5151 TranslatorInterface $ translator ,
5252 Environment $ twig
5353 ) {
5454 $ this ->importProcessor = $ importProcessor ;
5555 $ this ->formFactory = $ formFactory ;
56- $ this ->flashBag = $ flashBag ;
56+ $ this ->requestStack = $ requestStack ;
5757 $ this ->formErrorsFlashHelper = $ formErrorsFlashHelper ;
5858 $ this ->translator = $ translator ;
5959 $ this ->twig = $ twig ;
@@ -71,13 +71,14 @@ public function __invoke(Request $request): Response
7171 /** @var UploadedFile $file */
7272 $ file = $ form ->get ('file ' )->getData ();
7373 $ resourceName = $ request ->get ('resourceName ' );
74-
74+ $ session = $ this ->requestStack ->getSession ()->getFlashBag ();
75+
7576 try {
7677 $ this ->importProcessor ->process ($ resourceName , $ file ->getPathname ());
7778
78- $ this -> flashBag ->set ('success ' , $ this ->translator ->trans ('bitbag_sylius_cms_plugin.ui.successfully_imported ' ));
79+ $ session ->set ('success ' , $ this ->translator ->trans ('bitbag_sylius_cms_plugin.ui.successfully_imported ' ));
7980 } catch (ImportFailedException $ exception ) {
80- $ this -> flashBag ->set ('error ' , $ exception ->getMessage ());
81+ $ session ->set ('error ' , $ exception ->getMessage ());
8182 }
8283 } else {
8384 $ this ->formErrorsFlashHelper ->addFlashErrors ($ form );
0 commit comments