custom/plugins/VioB2BBudgets/src/Core/Checkout/Customer/Subscriber/CustomerTokenSubscriber.php line 31

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Vio\B2BBudget\Core\Checkout\Customer\Subscriber;
  3. use Shopware\Core\Checkout\Customer\CustomerEvents;
  4. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeletedEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\HttpFoundation\RequestStack;
  7. class CustomerTokenSubscriber implements EventSubscriberInterface
  8. {
  9.     private RequestStack $requestStack;
  10.     public function __construct(
  11.         RequestStack $requestStack
  12.     )
  13.     {
  14.         $this->requestStack $requestStack;
  15.     }
  16.     /**
  17.      * @inheritDoc
  18.      */
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             CustomerEvents::CUSTOMER_DELETED_EVENT => ['onCustomerDeleted'100]
  23.         ];
  24.     }
  25.     public function onCustomerDeleted(EntityDeletedEvent $event): void
  26.     {
  27.         $master $this->requestStack->getMasterRequest();
  28.         if (!$master) {
  29.             return;
  30.         }
  31.         if (!$master->attributes->has('_route')) {
  32.             return;
  33.         }
  34.         $route $master->attributes->get('_route');
  35.         if ($route === 'frontend.b2b.employee.budget.delete') {
  36.             $event->stopPropagation();
  37.         }
  38.     }
  39. }