Defined enum with supported remote systems

This commit is contained in:
Alejandro Celaya
2022-07-28 10:25:55 +02:00
parent e36c4d397c
commit 4cf433a994
10 changed files with 33 additions and 15 deletions

View File

@@ -8,5 +8,5 @@ abstract class AbstractAsyncListener
{
abstract protected function isEnabled(): bool;
abstract protected function getRemoteSystemName(): string;
abstract protected function getRemoteSystem(): RemoteSystem;
}

View File

@@ -30,7 +30,7 @@ abstract class AbstractNotifyNewShortUrlListener extends AbstractAsyncListener
$shortUrlId = $shortUrlCreated->shortUrlId;
$shortUrl = $this->em->find(ShortUrl::class, $shortUrlId);
$name = $this->getRemoteSystemName();
$name = $this->getRemoteSystem()->value;
if ($shortUrl === null) {
$this->logger->warning(

View File

@@ -33,7 +33,7 @@ abstract class AbstractNotifyVisitListener extends AbstractAsyncListener
$visitId = $visitLocated->visitId;
$visit = $this->em->find(Visit::class, $visitId);
$name = $this->getRemoteSystemName();
$name = $this->getRemoteSystem()->value;
if ($visit === null) {
$this->logger->warning(

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Core\EventDispatcher\Async;
enum RemoteSystem: string
{
case MERCURE = 'Mercure';
case RABBIT_MQ = 'RabbitMQ';
case REDIS_PUB_SUB = 'Redis pub/sub';
}