vendor/shopware/core/Framework/Event/EventAction/EventActionSubscriber.php line 36

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Event\EventAction;
  3. use Doctrine\DBAL\Connection;
  4. use Shopware\Core\Content\MailTemplate\MailTemplateEvents;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeletedEvent;
  6. use Shopware\Core\Framework\Feature;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. /**
  9.  * @deprecated tag:v6.5.0 - reason:remove-subscriber - Will be removed in v6.5.0.
  10.  */
  11. class EventActionSubscriber implements EventSubscriberInterface
  12. {
  13.     private Connection $connection;
  14.     /**
  15.      * @internal
  16.      */
  17.     public function __construct(Connection $connection)
  18.     {
  19.         $this->connection $connection;
  20.     }
  21.     /**
  22.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  23.      */
  24.     public static function getSubscribedEvents()
  25.     {
  26.         return [
  27.             MailTemplateEvents::MAIL_TEMPLATE_DELETED_EVENT => 'deleted',
  28.         ];
  29.     }
  30.     public function deleted(EntityDeletedEvent $event): void
  31.     {
  32.         if (Feature::isActive('FEATURE_NEXT_17858')) {
  33.             return;
  34.         }
  35.         $ids $event->getIds();
  36.         if (empty($ids)) {
  37.             return;
  38.         }
  39.         $this->connection->executeUpdate(
  40.             'DELETE FROM event_action
  41.              WHERE action_name = :action
  42.              AND JSON_UNQUOTE(JSON_EXTRACT(event_action.config, "$.mail_template_id")) IN (:ids)',
  43.             ['action' => 'action.mail.send''ids' => $ids],
  44.             ['ids' => Connection::PARAM_STR_ARRAY]
  45.         );
  46.     }
  47. }