custom/plugins/VioB2BLogin/src/Core/Checkout/Customer/Subscriber/CustomerTokenSubscriber.php line 30

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace VioB2BLogin\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.         $this->requestStack $requestStack;
  14.     }
  15.     /**
  16.      * @inheritDoc
  17.      */
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             CustomerEvents::CUSTOMER_DELETED_EVENT => ['onCustomerDeleted'100]
  22.         ];
  23.     }
  24.     public function onCustomerDeleted(EntityDeletedEvent $event): void
  25.     {
  26.         $master $this->requestStack->getMainRequest();
  27.         if (!$master) {
  28.             return;
  29.         }
  30.         if( !$master->attributes->has('_route') ) {
  31.             return;
  32.         }
  33.         $route $master->attributes->get('_route');
  34.         if( $route === 'frontend.b2b.employee.delete'
  35.         || $route === 'api.vio_b2b_employee.delete' ) {
  36.             $event->stopPropagation();
  37.         }
  38.     }
  39. }