diff --git a/module/Core/config/dependencies.config.php b/module/Core/config/dependencies.config.php index f4189dde..9edc5fc2 100644 --- a/module/Core/config/dependencies.config.php +++ b/module/Core/config/dependencies.config.php @@ -64,7 +64,7 @@ return [ ShortUrl\Transformer\ShortUrlDataTransformer::class => ConfigAbstractFactory::class, ShortUrl\Middleware\ExtraPathRedirectMiddleware::class => ConfigAbstractFactory::class, - Mercure\MercureUpdatesGenerator::class => ConfigAbstractFactory::class, + EventDispatcher\PublishingUpdatesGenerator::class => ConfigAbstractFactory::class, Importer\ImportedLinksProcessor::class => ConfigAbstractFactory::class, @@ -160,7 +160,7 @@ return [ Options\UrlShortenerOptions::class, ], - Mercure\MercureUpdatesGenerator::class => [ + EventDispatcher\PublishingUpdatesGenerator::class => [ ShortUrl\Transformer\ShortUrlDataTransformer::class, Visit\Transformer\OrphanVisitDataTransformer::class, ], diff --git a/module/Core/config/event_dispatcher.config.php b/module/Core/config/event_dispatcher.config.php index 4ac8f365..d2e3d08f 100644 --- a/module/Core/config/event_dispatcher.config.php +++ b/module/Core/config/event_dispatcher.config.php @@ -93,13 +93,13 @@ return [ ], EventDispatcher\Mercure\NotifyVisitToMercure::class => [ MercureHubPublishingHelper::class, - Mercure\MercureUpdatesGenerator::class, + EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', ], EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => [ MercureHubPublishingHelper::class, - Mercure\MercureUpdatesGenerator::class, + EventDispatcher\PublishingUpdatesGenerator::class, 'em', 'Logger_Shlink', ], diff --git a/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php b/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php index 15147403..fba3a57d 100644 --- a/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php +++ b/module/Core/src/EventDispatcher/Mercure/NotifyNewShortUrlToMercure.php @@ -9,14 +9,14 @@ use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; -use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Throwable; class NotifyNewShortUrlToMercure { public function __construct( private readonly PublishingHelperInterface $mercureHelper, - private readonly MercureUpdatesGeneratorInterface $updatesGenerator, + private readonly PublishingUpdatesGeneratorInterface $updatesGenerator, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, ) { diff --git a/module/Core/src/EventDispatcher/Mercure/NotifyVisitToMercure.php b/module/Core/src/EventDispatcher/Mercure/NotifyVisitToMercure.php index 6eab680c..cd55fcb2 100644 --- a/module/Core/src/EventDispatcher/Mercure/NotifyVisitToMercure.php +++ b/module/Core/src/EventDispatcher/Mercure/NotifyVisitToMercure.php @@ -10,7 +10,7 @@ use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated; -use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Throwable; use function Functional\each; @@ -19,7 +19,7 @@ class NotifyVisitToMercure { public function __construct( private readonly PublishingHelperInterface $mercureHelper, - private readonly MercureUpdatesGeneratorInterface $updatesGenerator, + private readonly PublishingUpdatesGeneratorInterface $updatesGenerator, private readonly EntityManagerInterface $em, private readonly LoggerInterface $logger, ) { diff --git a/module/Core/src/Mercure/MercureUpdatesGenerator.php b/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php similarity index 86% rename from module/Core/src/Mercure/MercureUpdatesGenerator.php rename to module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php index 33da0c6d..0f7de480 100644 --- a/module/Core/src/Mercure/MercureUpdatesGenerator.php +++ b/module/Core/src/EventDispatcher/PublishingUpdatesGenerator.php @@ -2,16 +2,14 @@ declare(strict_types=1); -namespace Shlinkio\Shlink\Core\Mercure; +namespace Shlinkio\Shlink\Core\EventDispatcher; use Shlinkio\Shlink\Common\Rest\DataTransformerInterface; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; -use Shlinkio\Shlink\Core\EventDispatcher\Topic; -// TODO This class can now be use in an agnostic way on all listeners -final class MercureUpdatesGenerator implements MercureUpdatesGeneratorInterface +final class PublishingUpdatesGenerator implements PublishingUpdatesGeneratorInterface { public function __construct( private readonly DataTransformerInterface $shortUrlTransformer, diff --git a/module/Core/src/Mercure/MercureUpdatesGeneratorInterface.php b/module/Core/src/EventDispatcher/PublishingUpdatesGeneratorInterface.php similarity index 82% rename from module/Core/src/Mercure/MercureUpdatesGeneratorInterface.php rename to module/Core/src/EventDispatcher/PublishingUpdatesGeneratorInterface.php index 732b6954..826157eb 100644 --- a/module/Core/src/Mercure/MercureUpdatesGeneratorInterface.php +++ b/module/Core/src/EventDispatcher/PublishingUpdatesGeneratorInterface.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Shlinkio\Shlink\Core\Mercure; +namespace Shlinkio\Shlink\Core\EventDispatcher; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; -interface MercureUpdatesGeneratorInterface +interface PublishingUpdatesGeneratorInterface { public function newVisitUpdate(Visit $visit): Update; diff --git a/module/Core/src/Visit/Transformer/OrphanVisitDataTransformer.php b/module/Core/src/Visit/Transformer/OrphanVisitDataTransformer.php index c9d30b8d..0da5f4ba 100644 --- a/module/Core/src/Visit/Transformer/OrphanVisitDataTransformer.php +++ b/module/Core/src/Visit/Transformer/OrphanVisitDataTransformer.php @@ -11,7 +11,6 @@ class OrphanVisitDataTransformer implements DataTransformerInterface { /** * @param Visit $visit - * @return array */ public function transform($visit): array // phpcs:ignore { diff --git a/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php b/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php index d360a15c..d0c89b3b 100644 --- a/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php +++ b/module/Core/test/EventDispatcher/Mercure/NotifyNewShortUrlToMercureTest.php @@ -16,7 +16,7 @@ use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated; use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyNewShortUrlToMercure; -use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; class NotifyNewShortUrlToMercureTest extends TestCase { @@ -31,7 +31,7 @@ class NotifyNewShortUrlToMercureTest extends TestCase protected function setUp(): void { $this->helper = $this->prophesize(PublishingHelperInterface::class); - $this->updatesGenerator = $this->prophesize(MercureUpdatesGeneratorInterface::class); + $this->updatesGenerator = $this->prophesize(PublishingUpdatesGeneratorInterface::class); $this->em = $this->prophesize(EntityManagerInterface::class); $this->logger = $this->prophesize(LoggerInterface::class); diff --git a/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php b/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php index a0ec417c..65049f49 100644 --- a/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php +++ b/module/Core/test/EventDispatcher/Mercure/NotifyVisitToMercureTest.php @@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated; use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyVisitToMercure; -use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface; +use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface; use Shlinkio\Shlink\Core\Model\Visitor; use Shlinkio\Shlink\Core\Visit\Model\VisitType; @@ -34,7 +34,7 @@ class NotifyVisitToMercureTest extends TestCase public function setUp(): void { $this->helper = $this->prophesize(PublishingHelperInterface::class); - $this->updatesGenerator = $this->prophesize(MercureUpdatesGeneratorInterface::class); + $this->updatesGenerator = $this->prophesize(PublishingUpdatesGeneratorInterface::class); $this->em = $this->prophesize(EntityManagerInterface::class); $this->logger = $this->prophesize(LoggerInterface::class); diff --git a/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php b/module/Core/test/EventDispatcher/PublishingUpdatesGeneratorTest.php similarity index 94% rename from module/Core/test/Mercure/MercureUpdatesGeneratorTest.php rename to module/Core/test/EventDispatcher/PublishingUpdatesGeneratorTest.php index 5e5910d7..e4b616e8 100644 --- a/module/Core/test/Mercure/MercureUpdatesGeneratorTest.php +++ b/module/Core/test/EventDispatcher/PublishingUpdatesGeneratorTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace ShlinkioTest\Shlink\Core\Mercure; +namespace ShlinkioTest\Shlink\Core\EventDispatcher; use PHPUnit\Framework\TestCase; use Shlinkio\Shlink\Common\UpdatePublishing\Update; use Shlinkio\Shlink\Core\Entity\ShortUrl; use Shlinkio\Shlink\Core\Entity\Visit; +use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGenerator; use Shlinkio\Shlink\Core\EventDispatcher\Topic; -use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGenerator; use Shlinkio\Shlink\Core\Model\ShortUrlMeta; use Shlinkio\Shlink\Core\Model\Visitor; use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier; @@ -17,13 +17,13 @@ use Shlinkio\Shlink\Core\ShortUrl\Transformer\ShortUrlDataTransformer; use Shlinkio\Shlink\Core\Visit\Model\VisitType; use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer; -class MercureUpdatesGeneratorTest extends TestCase +class PublishingUpdatesGeneratorTest extends TestCase { - private MercureUpdatesGenerator $generator; + private PublishingUpdatesGenerator $generator; public function setUp(): void { - $this->generator = new MercureUpdatesGenerator( + $this->generator = new PublishingUpdatesGenerator( new ShortUrlDataTransformer(new ShortUrlStringifier([])), new OrphanVisitDataTransformer(), );