1313
1414namespace Sylius \WishlistPlugin \Controller \Action ;
1515
16- use Sylius \Component \Order \Context \CartContextInterface ;
1716use Sylius \WishlistPlugin \Command \Wishlist \AddSelectedProductsToCart ;
1817use Sylius \WishlistPlugin \Exception \InsufficientProductStockException ;
1918use Sylius \WishlistPlugin \Exception \InvalidProductQuantityException ;
20- use Sylius \WishlistPlugin \Processor \WishlistCommandProcessorInterface ;
21- use Sylius \WishlistPlugin \Repository \WishlistRepositoryInterface ;
22- use Symfony \Component \Form \FormFactoryInterface ;
2319use Symfony \Component \Form \FormInterface ;
24- use Symfony \Component \HttpFoundation \RequestStack ;
2520use Symfony \Component \HttpFoundation \Session \Flash \FlashBagInterface ;
2621use Symfony \Component \HttpFoundation \Session \Session ;
2722use Symfony \Component \Messenger \Exception \HandlerFailedException ;
28- use Symfony \Component \Messenger \MessageBusInterface ;
29- use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
30- use Symfony \Contracts \Translation \TranslatorInterface ;
3123
3224final class AddSelectedProductsToCartAction extends BaseWishlistProductsAction
3325{
34- public function __construct (
35- CartContextInterface $ cartContext ,
36- FormFactoryInterface $ formFactory ,
37- RequestStack $ requestStack ,
38- WishlistCommandProcessorInterface $ wishlistCommandProcessor ,
39- MessageBusInterface $ messageBus ,
40- UrlGeneratorInterface $ urlGenerator ,
41- WishlistRepositoryInterface $ wishlistRepository ,
42- TranslatorInterface $ translator ,
43- ) {
44- parent ::__construct (
45- $ cartContext ,
46- $ formFactory ,
47- $ requestStack ,
48- $ wishlistCommandProcessor ,
49- $ messageBus ,
50- $ urlGenerator ,
51- $ wishlistRepository ,
52- $ translator ,
53- );
54- }
55-
5626 protected function handleCommand (FormInterface $ form ): void
5727 {
5828 try {
@@ -66,6 +36,14 @@ protected function handleCommand(FormInterface $form): void
6636 }
6737 }
6838
39+ protected function getFlashBag (): FlashBagInterface
40+ {
41+ /** @var Session $session */
42+ $ session = $ this ->requestStack ->getSession ();
43+
44+ return $ session ->getFlashBag ();
45+ }
46+
6947 private function getExceptionMessage (HandlerFailedException $ exception ): string
7048 {
7149 $ previous = $ exception ->getPrevious ();
@@ -78,12 +56,4 @@ private function getExceptionMessage(HandlerFailedException $exception): string
7856
7957 return $ exception ->getMessage ();
8058 }
81-
82- protected function getFlashBag (): FlashBagInterface
83- {
84- /** @var Session $session */
85- $ session = $ this ->requestStack ->getSession ();
86-
87- return $ session ->getFlashBag ();
88- }
8959}
0 commit comments