diff --git a/Classes/Command/DestinationDataImportCommand.php b/Classes/Command/DestinationDataImportCommand.php index 557b5fd..f1a643e 100644 --- a/Classes/Command/DestinationDataImportCommand.php +++ b/Classes/Command/DestinationDataImportCommand.php @@ -49,6 +49,11 @@ class DestinationDataImportCommand extends Command InputArgument::OPTIONAL, 'What is the region uid?' ); + $this->addArgument( + 'query', + InputArgument::OPTIONAL, + 'What is the additional query "q" parameter?' + ); } protected function execute(InputInterface $input, OutputInterface $output) @@ -62,11 +67,17 @@ class DestinationDataImportCommand extends Command $regionUid = null; } + $query = $input->getArgument('query'); + if (is_string($query) === false) { + $query = ''; + } + return $this->destinationDataImportService->import(new Import( $input->getArgument('rest-experience'), $input->getArgument('storage-pid'), $regionUid, - $input->getArgument('files-folder') + $input->getArgument('files-folder'), + $query )); } } diff --git a/Classes/Domain/DestinationData/Import.php b/Classes/Domain/DestinationData/Import.php index 9eadd51..9f5a6dc 100644 --- a/Classes/Domain/DestinationData/Import.php +++ b/Classes/Domain/DestinationData/Import.php @@ -28,16 +28,23 @@ class Import */ private $filesFolder; + /** + * @var string + */ + private $searchQuery; + public function __construct( string $restExperience, int $storagePid, ?int $regionUid, - string $filesFolder + string $filesFolder, + string $searchQuery ) { $this->restExperience = $restExperience; $this->storagePid = $storagePid; $this->regionUid = $regionUid; $this->filesFolder = $filesFolder; + $this->searchQuery = $searchQuery; } public function getRestExperience(): string @@ -59,4 +66,9 @@ class Import { return $this->filesFolder; } + + public function getSearchQuery(): string + { + return $this->searchQuery; + } } diff --git a/Classes/Service/DestinationDataImportService/UrlFactory.php b/Classes/Service/DestinationDataImportService/UrlFactory.php index 8f47dad..de89146 100644 --- a/Classes/Service/DestinationDataImportService/UrlFactory.php +++ b/Classes/Service/DestinationDataImportService/UrlFactory.php @@ -40,6 +40,7 @@ class UrlFactory 'mode' => $this->settings['restMode'] ?? '', 'limit' => $this->settings['restLimit'] ?? '', 'template' => $this->settings['restTemplate'] ?? '', + 'q' => $import->getSearchQuery() ]; $parameter = array_filter($parameter); diff --git a/Documentation/Changelog/2.3.0.rst b/Documentation/Changelog/2.3.0.rst new file mode 100644 index 0000000..fc0ea8e --- /dev/null +++ b/Documentation/Changelog/2.3.0.rst @@ -0,0 +1,30 @@ +2.3.0 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +* Add new option ``query`` to ``DestinationDataImportCommand``. + It is appended as ``q`` parameter to the initial search URL to fetch data for import. + The value is documented at https://developer.et4.de/reference/current/#eT4META-search-param-q.html. + Further documentation can be found at https://developer.et4.de/reference/current/#eT4META-search-querylanguage-Introduction.html. + +Fixes +----- + +Nothing + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing diff --git a/Tests/Unit/Domain/DestinationData/ImportTest.php b/Tests/Unit/Domain/DestinationData/ImportTest.php index eba8b53..b31e18b 100644 --- a/Tests/Unit/Domain/DestinationData/ImportTest.php +++ b/Tests/Unit/Domain/DestinationData/ImportTest.php @@ -19,6 +19,7 @@ class ImportTest extends TestCase '', 0, null, + '', '' ); @@ -37,6 +38,7 @@ class ImportTest extends TestCase 'experience', 0, null, + '', '' ); @@ -55,6 +57,7 @@ class ImportTest extends TestCase '', 20, null, + '', '' ); @@ -73,6 +76,7 @@ class ImportTest extends TestCase '', 0, 30, + '', '' ); @@ -91,7 +95,8 @@ class ImportTest extends TestCase '', 0, null, - 'test/folder' + 'test/folder', + '' ); self::assertSame( @@ -99,4 +104,23 @@ class ImportTest extends TestCase $subject->getFilesFolder() ); } + + /** + * @test + */ + public function returnsSearchQuery(): void + { + $subject = new Import( + '', + 0, + null, + 'test/folder', + 'name:"Test"' + ); + + self::assertSame( + 'name:"Test"', + $subject->getSearchQuery() + ); + } } diff --git a/Tests/Unit/Service/DestinationDataImportService/UrlFactoryTest.php b/Tests/Unit/Service/DestinationDataImportService/UrlFactoryTest.php index cf2ec0c..5f2ed94 100644 --- a/Tests/Unit/Service/DestinationDataImportService/UrlFactoryTest.php +++ b/Tests/Unit/Service/DestinationDataImportService/UrlFactoryTest.php @@ -74,6 +74,7 @@ class UrlFactoryTest extends TestCase 'import' => (function () { $import = $this->prophesize(Import::class); $import->getRestExperience()->willReturn('experience'); + $import->getSearchQuery()->willReturn(''); return $import; })(), @@ -91,6 +92,7 @@ class UrlFactoryTest extends TestCase 'import' => (function () { $import = $this->prophesize(Import::class); $import->getRestExperience()->willReturn(''); + $import->getSearchQuery()->willReturn(''); return $import; })(), @@ -103,6 +105,7 @@ class UrlFactoryTest extends TestCase 'import' => (function () { $import = $this->prophesize(Import::class); $import->getRestExperience()->willReturn('experience'); + $import->getSearchQuery()->willReturn(''); return $import; })(), @@ -114,6 +117,19 @@ class UrlFactoryTest extends TestCase ], 'expectedResult' => 'https://example.com/path?experience=experience&licensekey=licenseKey&limit=restLimit&template=restTemplate', ], + 'With search query' => [ + 'import' => (function () { + $import = $this->prophesize(Import::class); + $import->getRestExperience()->willReturn('experience'); + $import->getSearchQuery()->willReturn('name:"Test Something"'); + + return $import; + })(), + 'settings' => [ + 'restUrl' => 'https://example.com/path', + ], + 'expectedResult' => 'https://example.com/path?experience=experience&q=name%3A%22Test+Something%22', + ], ]; } }