From f832c56adbaea4b445b001025b64311043d04b34 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Thu, 21 Jul 2022 20:07:28 +0200 Subject: [PATCH] Moved Mercure and RabbitMq event listeners to their own subnamespaces --- .../Core/config/event_dispatcher.config.php | 20 +++++++++++------- .../EventDispatcher/Event/ShortUrlCreated.php | 21 +++++++++++++++++++ .../Mercure/NotifyNewShortUrlToMercure.php | 15 +++++++++++++ .../{ => Mercure}/NotifyVisitToMercure.php | 2 +- .../RabbitMq/NotifyNewShortUrlToRabbitMq.php | 15 +++++++++++++ .../{ => RabbitMq}/NotifyVisitToRabbitMq.php | 2 +- .../NotifyVisitToMercureTest.php | 4 ++-- .../NotifyVisitToRabbitMqTest.php | 6 +++--- 8 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 module/Core/src/EventDispatcher/Event/ShortUrlCreated.php create mode 100644 module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php rename module/Core/src/EventDispatcher/{ => Mercure}/NotifyVisitToMercure.php (97%) create mode 100644 module/Core/src/EventDispatcher/RabbitMq/NotifyNewShortUrlToRabbitMq.php rename module/Core/src/EventDispatcher/{ => RabbitMq}/NotifyVisitToRabbitMq.php (98%) rename module/Core/test/EventDispatcher/{ => Mercure}/NotifyVisitToMercureTest.php (98%) rename module/Core/test/EventDispatcher/{ => RabbitMq}/NotifyVisitToRabbitMqTest.php (96%) diff --git a/module/Core/config/event_dispatcher.config.php b/module/Core/config/event_dispatcher.config.php index d47cc128..e1342ebf 100644 --- a/module/Core/config/event_dispatcher.config.php +++ b/module/Core/config/event_dispatcher.config.php @@ -22,11 +22,15 @@ return [ ], 'async' => [ EventDispatcher\Event\VisitLocated::class => [ - EventDispatcher\NotifyVisitToMercure::class, - EventDispatcher\NotifyVisitToRabbitMq::class, + EventDispatcher\Mercure\NotifyVisitToMercure::class, + EventDispatcher\RabbitMq\NotifyVisitToRabbitMq::class, EventDispatcher\NotifyVisitToWebHooks::class, EventDispatcher\UpdateGeoLiteDb::class, ], +// EventDispatcher\Event\ShortUrlCreated::class => [ +// EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class, +// EventDispatcher\RabbitMq\NotifyNewShortUrlToRabbitMq::class, +// ], ], ], @@ -34,16 +38,16 @@ return [ 'factories' => [ EventDispatcher\LocateVisit::class => ConfigAbstractFactory::class, EventDispatcher\NotifyVisitToWebHooks::class => ConfigAbstractFactory::class, - EventDispatcher\NotifyVisitToMercure::class => ConfigAbstractFactory::class, - EventDispatcher\NotifyVisitToRabbitMq::class => ConfigAbstractFactory::class, + EventDispatcher\Mercure\NotifyVisitToMercure::class => ConfigAbstractFactory::class, + EventDispatcher\RabbitMq\NotifyVisitToRabbitMq::class => ConfigAbstractFactory::class, EventDispatcher\UpdateGeoLiteDb::class => ConfigAbstractFactory::class, ], 'delegators' => [ - EventDispatcher\NotifyVisitToMercure::class => [ + EventDispatcher\Mercure\NotifyVisitToMercure::class => [ EventDispatcher\CloseDbConnectionEventListenerDelegator::class, ], - EventDispatcher\NotifyVisitToRabbitMq::class => [ + EventDispatcher\RabbitMq\NotifyVisitToRabbitMq::class => [ EventDispatcher\CloseDbConnectionEventListenerDelegator::class, ], EventDispatcher\NotifyVisitToWebHooks::class => [ @@ -68,13 +72,13 @@ return [ ShortUrl\Transformer\ShortUrlDataTransformer::class, Options\AppOptions::class, ], - EventDispatcher\NotifyVisitToMercure::class => [ + EventDispatcher\Mercure\NotifyVisitToMercure::class => [ Hub::class, Mercure\MercureUpdatesGenerator::class, 'em', 'Logger_Shlink', ], - EventDispatcher\NotifyVisitToRabbitMq::class => [ + EventDispatcher\RabbitMq\NotifyVisitToRabbitMq::class => [ AMQPStreamConnection::class, 'em', 'Logger_Shlink', diff --git a/module/Core/src/EventDispatcher/Event/ShortUrlCreated.php b/module/Core/src/EventDispatcher/Event/ShortUrlCreated.php new file mode 100644 index 00000000..9786808f --- /dev/null +++ b/module/Core/src/EventDispatcher/Event/ShortUrlCreated.php @@ -0,0 +1,21 @@ + $this->shortUrlId, + ]; + } +} diff --git a/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php b/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php new file mode 100644 index 00000000..51fa3b58 --- /dev/null +++ b/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php @@ -0,0 +1,15 @@ +connection->reveal(), $this->em->reveal(), $this->logger->reveal(),