mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-14 04:00:57 +03:00
Extracted common logic from TagService to a private method
This commit is contained in:
parent
fd2a2530b1
commit
11a383b7e5
1 changed files with 8 additions and 4 deletions
|
@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Core\Tag;
|
|||
|
||||
use Doctrine\ORM;
|
||||
use Happyr\DoctrineSpecification\Spec;
|
||||
use Pagerfanta\Adapter\AdapterInterface;
|
||||
use Pagerfanta\Adapter\ArrayAdapter;
|
||||
use Shlinkio\Shlink\Common\Paginator\Paginator;
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
|
@ -38,9 +39,7 @@ class TagService implements TagServiceInterface
|
|||
new WithApiKeySpecsEnsuringJoin($apiKey),
|
||||
));
|
||||
|
||||
return (new Paginator(new ArrayAdapter($tags)))
|
||||
->setMaxPerPage($params->getItemsPerPage())
|
||||
->setCurrentPage($params->getPage());
|
||||
return $this->createPaginator(new ArrayAdapter($tags), $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,7 +51,12 @@ class TagService implements TagServiceInterface
|
|||
$repo = $this->em->getRepository(Tag::class);
|
||||
$tagsInfo = $repo->findTagsWithInfo($apiKey);
|
||||
|
||||
return (new Paginator(new ArrayAdapter($tagsInfo)))
|
||||
return $this->createPaginator(new ArrayAdapter($tagsInfo), $params);
|
||||
}
|
||||
|
||||
private function createPaginator(AdapterInterface $adapter, TagsParams $params): Paginator
|
||||
{
|
||||
return (new Paginator($adapter))
|
||||
->setMaxPerPage($params->getItemsPerPage())
|
||||
->setCurrentPage($params->getPage());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue