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

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