mirror of
https://github.com/werkraum-media/events.git
synced 2024-12-25 05:46:10 +01:00
parent
8044ddf30f
commit
4bc4f34525
6 changed files with 97 additions and 3 deletions
|
@ -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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
30
Documentation/Changelog/2.3.0.rst
Normal file
30
Documentation/Changelog/2.3.0.rst
Normal file
|
@ -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
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue