custom/plugins/MolliePayments/src/Subscriber/SalesChannelContextTokenChangedSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Kiener\MolliePayments\Subscriber;
  4. use Kiener\MolliePayments\Service\Cart\CartBackupService;
  5. use Shopware\Core\System\SalesChannel\Event\SalesChannelContextTokenChangeEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class SalesChannelContextTokenChangedSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var CartBackupService
  11.      */
  12.     private $cartBackupService;
  13.     public function __construct(CartBackupService $cartBackupService)
  14.     {
  15.         $this->cartBackupService $cartBackupService;
  16.     }
  17.     public static function getSubscribedEvents()
  18.     {
  19.         return [
  20.             SalesChannelContextTokenChangeEvent::class => 'onTokenChange',
  21.         ];
  22.     }
  23.     public function onTokenChange(SalesChannelContextTokenChangeEvent $event): void
  24.     {
  25.         $this->cartBackupService->replaceToken($event->getPreviousToken(), $event->getCurrentToken(), $event->getSalesChannelContext());
  26.     }
  27. }