Changed VisitsCountFiltering and VisitsListFiltering so that they encapsulate an ApiKey instead of a Spec

This commit is contained in:
Alejandro Celaya
2022-01-16 10:56:37 +01:00
parent 3436405c55
commit 60c0ca3ae5
10 changed files with 33 additions and 29 deletions

View File

@@ -51,18 +51,19 @@ class VisitsStatsHelper implements VisitsStatsHelperInterface
VisitsParams $params,
?ApiKey $apiKey = null,
): Paginator {
$spec = $apiKey?->spec();
/** @var ShortUrlRepositoryInterface $repo */
$repo = $this->em->getRepository(ShortUrl::class);
if (! $repo->shortCodeIsInUse($identifier, $spec)) {
if (! $repo->shortCodeIsInUse($identifier, $apiKey?->spec())) {
throw ShortUrlNotFoundException::fromNotFound($identifier);
}
/** @var VisitRepositoryInterface $repo */
$repo = $this->em->getRepository(Visit::class);
return $this->createPaginator(new ShortUrlVisitsPaginatorAdapter($repo, $identifier, $params, $spec), $params);
return $this->createPaginator(
new ShortUrlVisitsPaginatorAdapter($repo, $identifier, $params, $apiKey),
$params,
);
}
/**