diff --git a/composer.json b/composer.json index 16378c67..762ead49 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "shlinkio/shlink-common": "dev-main#7515008 as 5.2", "shlinkio/shlink-config": "dev-main#96c81fb as 2.3", "shlinkio/shlink-event-dispatcher": "^2.6", - "shlinkio/shlink-importer": "^4.0", + "shlinkio/shlink-importer": "dev-main#c97662b as 5.0", "shlinkio/shlink-installer": "^8.2", "shlinkio/shlink-ip-geolocation": "dev-main#e208963 as 3.2", "spiral/roadrunner": "^2.11", diff --git a/module/Core/src/Importer/ImportedLinksProcessor.php b/module/Core/src/Importer/ImportedLinksProcessor.php index 0f28c7fa..b33670ac 100644 --- a/module/Core/src/Importer/ImportedLinksProcessor.php +++ b/module/Core/src/Importer/ImportedLinksProcessor.php @@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface; use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface; use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl; +use Shlinkio\Shlink\Importer\Model\ImportResult; use Shlinkio\Shlink\Importer\Params\ImportParams; use Shlinkio\Shlink\Importer\Sources\ImportSource; use Symfony\Component\Console\Style\OutputStyle; @@ -34,14 +35,11 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface $this->shortUrlRepo = $this->em->getRepository(ShortUrl::class); } - /** - * @param iterable $shlinkUrls - */ - public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void + public function process(StyleInterface $io, ImportResult $result, ImportParams $params): void { $importShortCodes = $params->importShortCodes; $source = $params->source; - $iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100); + $iterable = $this->batchHelper->wrapIterable($result->shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100); /** @var ImportedShlinkUrl $importedUrl */ foreach ($iterable as $importedUrl) { diff --git a/module/Core/test/Importer/ImportedLinksProcessorTest.php b/module/Core/test/Importer/ImportedLinksProcessorTest.php index 382d912c..a419858f 100644 --- a/module/Core/test/Importer/ImportedLinksProcessorTest.php +++ b/module/Core/test/Importer/ImportedLinksProcessorTest.php @@ -19,6 +19,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface; use Shlinkio\Shlink\Core\Visit\Entity\Visit; use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl; use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit; +use Shlinkio\Shlink\Importer\Model\ImportResult; use Shlinkio\Shlink\Importer\Params\ImportParams; use Shlinkio\Shlink\Importer\Sources\ImportSource; use stdClass; @@ -76,7 +77,7 @@ class ImportedLinksProcessorTest extends TestCase ); $this->io->expects($this->exactly($expectedCalls))->method('text')->with($this->isType('string')); - $this->processor->process($this->io, $urls, $this->buildParams()); + $this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams()); } /** @test */ @@ -99,7 +100,7 @@ class ImportedLinksProcessorTest extends TestCase }); $textCalls = $this->setUpIoText('Skipped. Reason: Whatever error', 'Imported'); - $this->processor->process($this->io, $urls, $this->buildParams()); + $this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams()); self::assertEquals(2, $textCalls->importedCount); self::assertEquals(1, $textCalls->skippedCount); @@ -124,7 +125,7 @@ class ImportedLinksProcessorTest extends TestCase $this->em->expects($this->exactly(2))->method('persist')->with($this->isInstanceOf(ShortUrl::class)); $textCalls = $this->setUpIoText(); - $this->processor->process($this->io, $urls, $this->buildParams()); + $this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams()); self::assertEquals(2, $textCalls->importedCount); self::assertEquals(3, $textCalls->skippedCount); @@ -151,7 +152,7 @@ class ImportedLinksProcessorTest extends TestCase }); $textCalls = $this->setUpIoText('Error'); - $this->processor->process($this->io, $urls, $this->buildParams()); + $this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams()); self::assertEquals(2, $textCalls->importedCount); self::assertEquals(3, $textCalls->skippedCount); @@ -176,7 +177,7 @@ class ImportedLinksProcessorTest extends TestCase )->with($this->callback(fn (object $arg) => $arg instanceof ShortUrl || $arg instanceof Visit)); $this->io->expects($this->once())->method('text')->with($this->stringContains($expectedOutput)); - $this->processor->process($this->io, [$importedUrl], $this->buildParams()); + $this->processor->process($this->io, ImportResult::withShortUrls([$importedUrl]), $this->buildParams()); } public function provideUrlsWithVisits(): iterable