vendor/shopware/platform/src/Storefront/Event/CartMergedSubscriber.php line 37

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Event;
  3. use Shopware\Core\Checkout\Cart\Event\CartMergedEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpFoundation\Session\Session;
  6. use Symfony\Contracts\Translation\TranslatorInterface;
  7. class CartMergedSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var Session
  11.      */
  12.     private $session;
  13.     /**
  14.      * @var TranslatorInterface
  15.      */
  16.     private $translator;
  17.     public function __construct(
  18.         Session $session,
  19.         TranslatorInterface $translator
  20.     ) {
  21.         $this->session $session;
  22.         $this->translator $translator;
  23.     }
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             CartMergedEvent::class => 'addCartMergedNoticeFlash',
  28.         ];
  29.     }
  30.     public function addCartMergedNoticeFlash(CartMergedEvent $event): void
  31.     {
  32.         $this->session->getFlashBag()->add('info'$this->translator->trans('checkout.cart-merged-hint'));
  33.     }
  34. }