mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Moved event objects to a sub-namespace inside Core\EventDispatcher
This commit is contained in:
@@ -14,13 +14,13 @@ return [
|
|||||||
|
|
||||||
'events' => [
|
'events' => [
|
||||||
'regular' => [
|
'regular' => [
|
||||||
EventDispatcher\VisitLocated::class => [
|
EventDispatcher\Event\VisitLocated::class => [
|
||||||
EventDispatcher\NotifyVisitToMercure::class,
|
EventDispatcher\NotifyVisitToMercure::class,
|
||||||
EventDispatcher\NotifyVisitToWebHooks::class,
|
EventDispatcher\NotifyVisitToWebHooks::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'async' => [
|
'async' => [
|
||||||
EventDispatcher\ShortUrlVisited::class => [
|
EventDispatcher\Event\ShortUrlVisited::class => [
|
||||||
EventDispatcher\LocateShortUrlVisit::class,
|
EventDispatcher\LocateShortUrlVisit::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|||||||
27
module/Core/src/EventDispatcher/Event/AbstractVisitEvent.php
Normal file
27
module/Core/src/EventDispatcher/Event/AbstractVisitEvent.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Shlinkio\Shlink\Core\EventDispatcher\Event;
|
||||||
|
|
||||||
|
use JsonSerializable;
|
||||||
|
|
||||||
|
abstract class AbstractVisitEvent implements JsonSerializable
|
||||||
|
{
|
||||||
|
protected string $visitId;
|
||||||
|
|
||||||
|
public function __construct(string $visitId)
|
||||||
|
{
|
||||||
|
$this->visitId = $visitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function visitId(): string
|
||||||
|
{
|
||||||
|
return $this->visitId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize(): array
|
||||||
|
{
|
||||||
|
return ['visitId' => $this->visitId];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,33 +2,20 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
namespace Shlinkio\Shlink\Core\EventDispatcher\Event;
|
||||||
|
|
||||||
use JsonSerializable;
|
final class ShortUrlVisited extends AbstractVisitEvent
|
||||||
|
|
||||||
final class ShortUrlVisited implements JsonSerializable
|
|
||||||
{
|
{
|
||||||
private string $visitId;
|
|
||||||
private ?string $originalIpAddress;
|
private ?string $originalIpAddress;
|
||||||
|
|
||||||
public function __construct(string $visitId, ?string $originalIpAddress = null)
|
public function __construct(string $visitId, ?string $originalIpAddress = null)
|
||||||
{
|
{
|
||||||
$this->visitId = $visitId;
|
parent::__construct($visitId);
|
||||||
$this->originalIpAddress = $originalIpAddress;
|
$this->originalIpAddress = $originalIpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function visitId(): string
|
|
||||||
{
|
|
||||||
return $this->visitId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function originalIpAddress(): ?string
|
public function originalIpAddress(): ?string
|
||||||
{
|
{
|
||||||
return $this->originalIpAddress;
|
return $this->originalIpAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSerialize(): array
|
|
||||||
{
|
|
||||||
return ['visitId' => $this->visitId, 'originalIpAddress' => '<censored>'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,26 +2,8 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
namespace Shlinkio\Shlink\Core\EventDispatcher\Event;
|
||||||
|
|
||||||
use JsonSerializable;
|
final class VisitLocated extends AbstractVisitEvent
|
||||||
|
|
||||||
final class VisitLocated implements JsonSerializable
|
|
||||||
{
|
{
|
||||||
private string $visitId;
|
|
||||||
|
|
||||||
public function __construct(string $visitId)
|
|
||||||
{
|
|
||||||
$this->visitId = $visitId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function visitId(): string
|
|
||||||
{
|
|
||||||
return $this->visitId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function jsonSerialize(): array
|
|
||||||
{
|
|
||||||
return ['visitId' => $this->visitId];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ use Shlinkio\Shlink\CLI\Exception\GeolocationDbUpdateFailedException;
|
|||||||
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdaterInterface;
|
use Shlinkio\Shlink\CLI\Util\GeolocationDbUpdaterInterface;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlVisited;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
|
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
use Shlinkio\Shlink\IpGeolocation\Resolver\IpLocationResolverInterface;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Shlinkio\Shlink\Core\EventDispatcher;
|
|||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
||||||
use Symfony\Component\Mercure\PublisherInterface;
|
use Symfony\Component\Mercure\PublisherInterface;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use GuzzleHttp\Promise\PromiseInterface;
|
|||||||
use GuzzleHttp\RequestOptions;
|
use GuzzleHttp\RequestOptions;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||||
use Shlinkio\Shlink\Core\Transformer\ShortUrlDataTransformer;
|
use Shlinkio\Shlink\Core\Transformer\ShortUrlDataTransformer;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use Psr\EventDispatcher\EventDispatcherInterface;
|
|||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\ShortUrlVisited;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlVisited;
|
||||||
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
||||||
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
||||||
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
|
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ use Shlinkio\Shlink\Common\Util\IpAddress;
|
|||||||
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\Entity\VisitLocation;
|
use Shlinkio\Shlink\Core\Entity\VisitLocation;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlVisited;
|
||||||
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\LocateShortUrlVisit;
|
use Shlinkio\Shlink\Core\EventDispatcher\LocateShortUrlVisit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\ShortUrlVisited;
|
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\VisitLocated;
|
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
|
use Shlinkio\Shlink\IpGeolocation\Exception\WrongIpException;
|
||||||
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
use Shlinkio\Shlink\IpGeolocation\Model\Location;
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use Psr\Log\LoggerInterface;
|
|||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
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\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToMercure;
|
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToMercure;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\VisitLocated;
|
|
||||||
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
use Shlinkio\Shlink\Core\Mercure\MercureUpdatesGeneratorInterface;
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Symfony\Component\Mercure\PublisherInterface;
|
use Symfony\Component\Mercure\PublisherInterface;
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ use Prophecy\Prophecy\ObjectProphecy;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
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\Event\VisitLocated;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToWebHooks;
|
use Shlinkio\Shlink\Core\EventDispatcher\NotifyVisitToWebHooks;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\VisitLocated;
|
|
||||||
use Shlinkio\Shlink\Core\Model\Visitor;
|
use Shlinkio\Shlink\Core\Model\Visitor;
|
||||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use Shlinkio\Shlink\Common\Util\DateRange;
|
|||||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\ShortUrlVisited;
|
use Shlinkio\Shlink\Core\EventDispatcher\Event\ShortUrlVisited;
|
||||||
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
use Shlinkio\Shlink\Core\Exception\ShortUrlNotFoundException;
|
||||||
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
use Shlinkio\Shlink\Core\Exception\TagNotFoundException;
|
||||||
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
|
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
|
||||||
|
|||||||
Reference in New Issue
Block a user