mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-07 06:34:05 -06:00
Renamed MercureUpdatesGenerator to PublishingUpdatesGenerator to make it general purpose
This commit is contained in:
parent
d3add6d8e4
commit
7e8109caa3
@ -64,7 +64,7 @@ return [
|
|||||||
ShortUrl\Transformer\ShortUrlDataTransformer::class => ConfigAbstractFactory::class,
|
ShortUrl\Transformer\ShortUrlDataTransformer::class => ConfigAbstractFactory::class,
|
||||||
ShortUrl\Middleware\ExtraPathRedirectMiddleware::class => ConfigAbstractFactory::class,
|
ShortUrl\Middleware\ExtraPathRedirectMiddleware::class => ConfigAbstractFactory::class,
|
||||||
|
|
||||||
Mercure\MercureUpdatesGenerator::class => ConfigAbstractFactory::class,
|
EventDispatcher\PublishingUpdatesGenerator::class => ConfigAbstractFactory::class,
|
||||||
|
|
||||||
Importer\ImportedLinksProcessor::class => ConfigAbstractFactory::class,
|
Importer\ImportedLinksProcessor::class => ConfigAbstractFactory::class,
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ return [
|
|||||||
Options\UrlShortenerOptions::class,
|
Options\UrlShortenerOptions::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
Mercure\MercureUpdatesGenerator::class => [
|
EventDispatcher\PublishingUpdatesGenerator::class => [
|
||||||
ShortUrl\Transformer\ShortUrlDataTransformer::class,
|
ShortUrl\Transformer\ShortUrlDataTransformer::class,
|
||||||
Visit\Transformer\OrphanVisitDataTransformer::class,
|
Visit\Transformer\OrphanVisitDataTransformer::class,
|
||||||
],
|
],
|
||||||
|
@ -93,13 +93,13 @@ return [
|
|||||||
],
|
],
|
||||||
EventDispatcher\Mercure\NotifyVisitToMercure::class => [
|
EventDispatcher\Mercure\NotifyVisitToMercure::class => [
|
||||||
MercureHubPublishingHelper::class,
|
MercureHubPublishingHelper::class,
|
||||||
Mercure\MercureUpdatesGenerator::class,
|
EventDispatcher\PublishingUpdatesGenerator::class,
|
||||||
'em',
|
'em',
|
||||||
'Logger_Shlink',
|
'Logger_Shlink',
|
||||||
],
|
],
|
||||||
EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => [
|
EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => [
|
||||||
MercureHubPublishingHelper::class,
|
MercureHubPublishingHelper::class,
|
||||||
Mercure\MercureUpdatesGenerator::class,
|
EventDispatcher\PublishingUpdatesGenerator::class,
|
||||||
'em',
|
'em',
|
||||||
'Logger_Shlink',
|
'Logger_Shlink',
|
||||||
],
|
],
|
||||||
|
@ -9,14 +9,14 @@ use Psr\Log\LoggerInterface;
|
|||||||
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class NotifyNewShortUrlToMercure
|
class NotifyNewShortUrlToMercure
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly PublishingHelperInterface $mercureHelper,
|
private readonly PublishingHelperInterface $mercureHelper,
|
||||||
private readonly MercureUpdatesGeneratorInterface $updatesGenerator,
|
private readonly PublishingUpdatesGeneratorInterface $updatesGenerator,
|
||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
|
@ -10,7 +10,7 @@ use Shlinkio\Shlink\Common\UpdatePublishing\PublishingHelperInterface;
|
|||||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
use function Functional\each;
|
use function Functional\each;
|
||||||
@ -19,7 +19,7 @@ class NotifyVisitToMercure
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly PublishingHelperInterface $mercureHelper,
|
private readonly PublishingHelperInterface $mercureHelper,
|
||||||
private readonly MercureUpdatesGeneratorInterface $updatesGenerator,
|
private readonly PublishingUpdatesGeneratorInterface $updatesGenerator,
|
||||||
private readonly EntityManagerInterface $em,
|
private readonly EntityManagerInterface $em,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
) {
|
) {
|
||||||
|
@ -2,16 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Core\Mercure;
|
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
||||||
|
|
||||||
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
use Shlinkio\Shlink\Common\Rest\DataTransformerInterface;
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
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 PublishingUpdatesGenerator implements PublishingUpdatesGeneratorInterface
|
||||||
final class MercureUpdatesGenerator implements MercureUpdatesGeneratorInterface
|
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly DataTransformerInterface $shortUrlTransformer,
|
private readonly DataTransformerInterface $shortUrlTransformer,
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Core\Mercure;
|
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
||||||
|
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
|
||||||
interface MercureUpdatesGeneratorInterface
|
interface PublishingUpdatesGeneratorInterface
|
||||||
{
|
{
|
||||||
public function newVisitUpdate(Visit $visit): Update;
|
public function newVisitUpdate(Visit $visit): Update;
|
||||||
|
|
@ -11,7 +11,6 @@ class OrphanVisitDataTransformer implements DataTransformerInterface
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param Visit $visit
|
* @param Visit $visit
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function transform($visit): array // phpcs:ignore
|
public function transform($visit): array // phpcs:ignore
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
|||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlCreated;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyNewShortUrlToMercure;
|
use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyNewShortUrlToMercure;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGeneratorInterface;
|
||||||
|
|
||||||
class NotifyNewShortUrlToMercureTest extends TestCase
|
class NotifyNewShortUrlToMercureTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ class NotifyNewShortUrlToMercureTest extends TestCase
|
|||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->helper = $this->prophesize(PublishingHelperInterface::class);
|
$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->em = $this->prophesize(EntityManagerInterface::class);
|
||||||
$this->logger = $this->prophesize(LoggerInterface::class);
|
$this->logger = $this->prophesize(LoggerInterface::class);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
|||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Mercure\NotifyVisitToMercure;
|
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\Model\Visitor;
|
||||||
use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
use Shlinkio\Shlink\Core\Visit\Model\VisitType;
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class NotifyVisitToMercureTest extends TestCase
|
|||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->helper = $this->prophesize(PublishingHelperInterface::class);
|
$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->em = $this->prophesize(EntityManagerInterface::class);
|
||||||
$this->logger = $this->prophesize(LoggerInterface::class);
|
$this->logger = $this->prophesize(LoggerInterface::class);
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace ShlinkioTest\Shlink\Core\Mercure;
|
namespace ShlinkioTest\Shlink\Core\EventDispatcher;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
use Shlinkio\Shlink\Common\UpdatePublishing\Update;
|
||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\PublishingUpdatesGenerator;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
use Shlinkio\Shlink\Core\EventDispatcher\Topic;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGenerator;
|
|
||||||
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
use Shlinkio\Shlink\Core\Model\ShortUrlMeta;
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
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\Model\VisitType;
|
||||||
use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer;
|
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
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->generator = new MercureUpdatesGenerator(
|
$this->generator = new PublishingUpdatesGenerator(
|
||||||
new ShortUrlDataTransformer(new ShortUrlStringifier([])),
|
new ShortUrlDataTransformer(new ShortUrlStringifier([])),
|
||||||
new OrphanVisitDataTransformer(),
|
new OrphanVisitDataTransformer(),
|
||||||
);
|
);
|
Loading…
Reference in New Issue
Block a user