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

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 Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class EventActionSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var Connection
  11.      */
  12.     private $connection;
  13.     public function __construct(Connection $connection)
  14.     {
  15.         $this->connection $connection;
  16.     }
  17.     public static function getSubscribedEvents()
  18.     {
  19.         return [
  20.             MailTemplateEvents::MAIL_TEMPLATE_DELETED_EVENT => 'deleted',
  21.         ];
  22.     }
  23.     public function deleted(EntityDeletedEvent $event): void
  24.     {
  25.         $ids $event->getIds();
  26.         if (empty($ids)) {
  27.             return;
  28.         }
  29.         $this->connection->executeUpdate(
  30.             'DELETE FROM event_action
  31.              WHERE action_name = :action
  32.              AND JSON_UNQUOTE(JSON_EXTRACT(event_action.config, "$.mail_template_id")) IN (:ids)',
  33.             ['action' => 'action.mail.send''ids' => $ids],
  34.             ['ids' => Connection::PARAM_STR_ARRAY]
  35.         );
  36.     }
  37. }