Extracted method to find crawlable short codes to its own query object

This commit is contained in:
Alejandro Celaya
2022-12-14 14:38:22 +01:00
parent 73c8b53882
commit 60ef98b836
9 changed files with 114 additions and 80 deletions

View File

@@ -4,20 +4,16 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Core\Crawling;
use Doctrine\ORM\EntityManagerInterface;
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
use Shlinkio\Shlink\Core\ShortUrl\Repository\CrawlableShortCodesQueryInterface;
class CrawlingHelper implements CrawlingHelperInterface
{
public function __construct(private EntityManagerInterface $em)
public function __construct(private readonly CrawlableShortCodesQueryInterface $query)
{
}
public function listCrawlableShortCodes(): iterable
{
/** @var ShortUrlRepositoryInterface $repo */
$repo = $this->em->getRepository(ShortUrl::class);
yield from $repo->findCrawlableShortCodes();
yield from ($this->query)();
}
}