diff --git a/config/autoload/routes.config.php b/config/autoload/routes.config.php index c887d5b7..93464519 100644 --- a/config/autoload/routes.config.php +++ b/config/autoload/routes.config.php @@ -53,6 +53,7 @@ return (static function (): array { ]), Action\ShortUrl\EditShortUrlAction::getRouteDef([$dropDomainMiddleware]), Action\ShortUrl\DeleteShortUrlAction::getRouteDef([$dropDomainMiddleware]), + Action\ShortUrl\DeleteShortUrlVisitsAction::getRouteDef([$dropDomainMiddleware]), Action\ShortUrl\ResolveShortUrlAction::getRouteDef([$dropDomainMiddleware]), Action\ShortUrl\ListShortUrlsAction::getRouteDef(), diff --git a/module/Core/config/dependencies.config.php b/module/Core/config/dependencies.config.php index 008db777..8e3e9a52 100644 --- a/module/Core/config/dependencies.config.php +++ b/module/Core/config/dependencies.config.php @@ -38,6 +38,7 @@ return [ ShortUrl\ShortUrlListService::class => ConfigAbstractFactory::class, ShortUrl\DeleteShortUrlService::class => ConfigAbstractFactory::class, ShortUrl\ShortUrlResolver::class => ConfigAbstractFactory::class, + ShortUrl\ShortUrlVisitsDeleter::class => ConfigAbstractFactory::class, ShortUrl\Helper\ShortCodeUniquenessHelper::class => ConfigAbstractFactory::class, ShortUrl\Resolver\PersistenceShortUrlRelationResolver::class => ConfigAbstractFactory::class, ShortUrl\Helper\ShortUrlStringifier::class => ConfigAbstractFactory::class, @@ -69,6 +70,10 @@ return [ EntityRepositoryFactory::class, Visit\Entity\Visit::class, ], + Visit\Repository\VisitDeleterRepository::class => [ + EntityRepositoryFactory::class, + Visit\Entity\Visit::class, + ], Util\UrlValidator::class => ConfigAbstractFactory::class, Util\DoctrineBatchHelper::class => ConfigAbstractFactory::class, @@ -137,6 +142,10 @@ return [ ShortUrl\ShortUrlResolver::class, ], ShortUrl\ShortUrlResolver::class => ['em', Options\UrlShortenerOptions::class], + ShortUrl\ShortUrlVisitsDeleter::class => [ + Visit\Repository\VisitDeleterRepository::class, + ShortUrl\ShortUrlResolver::class, + ], ShortUrl\Helper\ShortCodeUniquenessHelper::class => ['em', Options\UrlShortenerOptions::class], Domain\DomainService::class => ['em', 'config.url_shortener.domain.hostname'], diff --git a/module/Core/src/Model/BulkDeleteResult.php b/module/Core/src/Model/BulkDeleteResult.php new file mode 100644 index 00000000..b3b0e756 --- /dev/null +++ b/module/Core/src/Model/BulkDeleteResult.php @@ -0,0 +1,17 @@ + $this->affectedItems]; + } +} diff --git a/module/Core/src/ShortUrl/ShortUrlVisitsDeleter.php b/module/Core/src/ShortUrl/ShortUrlVisitsDeleter.php new file mode 100644 index 00000000..097c8875 --- /dev/null +++ b/module/Core/src/ShortUrl/ShortUrlVisitsDeleter.php @@ -0,0 +1,25 @@ +resolver->resolveShortUrl($identifier, $apiKey); + return new BulkDeleteResult($this->repository->deleteShortUrlVisits($identifier, $apiKey)); + } +} diff --git a/module/Core/src/ShortUrl/ShortUrlVisitsDeleterInterface.php b/module/Core/src/ShortUrl/ShortUrlVisitsDeleterInterface.php new file mode 100644 index 00000000..dc29ef94 --- /dev/null +++ b/module/Core/src/ShortUrl/ShortUrlVisitsDeleterInterface.php @@ -0,0 +1,14 @@ + ConfigAbstractFactory::class, Action\ShortUrl\ResolveShortUrlAction::class => ConfigAbstractFactory::class, Action\ShortUrl\ListShortUrlsAction::class => ConfigAbstractFactory::class, + Action\ShortUrl\DeleteShortUrlVisitsAction::class => ConfigAbstractFactory::class, Action\Visit\ShortUrlVisitsAction::class => ConfigAbstractFactory::class, Action\Visit\TagVisitsAction::class => ConfigAbstractFactory::class, Action\Visit\DomainVisitsAction::class => ConfigAbstractFactory::class, @@ -94,6 +95,7 @@ return [ ShortUrl\ShortUrlListService::class, ShortUrlDataTransformer::class, ], + Action\ShortUrl\DeleteShortUrlVisitsAction::class => [ShortUrl\ShortUrlVisitsDeleter::class], Action\Tag\ListTagsAction::class => [TagService::class], Action\Tag\TagsStatsAction::class => [TagService::class], Action\Tag\DeleteTagsAction::class => [TagService::class], diff --git a/module/Rest/src/Action/ShortUrl/DeleteShortUrlVisitsAction.php b/module/Rest/src/Action/ShortUrl/DeleteShortUrlVisitsAction.php new file mode 100644 index 00000000..c9eaf958 --- /dev/null +++ b/module/Rest/src/Action/ShortUrl/DeleteShortUrlVisitsAction.php @@ -0,0 +1,33 @@ +deleter->deleteShortUrlVisits($identifier, $apiKey); + + return new JsonResponse($result->toArray('deletedVisits')); + } +}