2019-08-12 07:43:37 +02:00
|
|
|
<?php
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2019-08-12 07:43:37 +02:00
|
|
|
namespace Wrm\Events\Command;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
use TYPO3\CMS\Core\Core\Bootstrap;
|
2022-01-27 14:14:02 +01:00
|
|
|
use Wrm\Events\Domain\DestinationData\LegacyImportFactory;
|
2019-08-13 11:17:34 +02:00
|
|
|
use Wrm\Events\Service\DestinationDataImportService;
|
2019-08-12 07:43:37 +02:00
|
|
|
|
2021-01-07 08:50:43 +01:00
|
|
|
class DestinationDataImportCommand extends Command
|
|
|
|
{
|
2021-12-14 16:09:42 +01:00
|
|
|
/**
|
|
|
|
* @var DestinationDataImportService
|
|
|
|
*/
|
|
|
|
private $destinationDataImportService;
|
|
|
|
|
2022-01-27 14:14:02 +01:00
|
|
|
/**
|
|
|
|
* @var LegacyImportFactory
|
|
|
|
*/
|
|
|
|
private $importFactory;
|
|
|
|
|
2021-12-14 16:09:42 +01:00
|
|
|
public function __construct(
|
2022-01-27 14:14:02 +01:00
|
|
|
DestinationDataImportService $destinationDataImportService,
|
|
|
|
LegacyImportFactory $importFactory
|
2021-12-14 16:09:42 +01:00
|
|
|
) {
|
|
|
|
parent::__construct();
|
|
|
|
$this->destinationDataImportService = $destinationDataImportService;
|
2022-01-27 14:14:02 +01:00
|
|
|
$this->importFactory = $importFactory;
|
2021-12-14 16:09:42 +01:00
|
|
|
}
|
|
|
|
|
2021-09-07 09:52:14 +02:00
|
|
|
public function configure(): void
|
2019-08-12 07:43:37 +02:00
|
|
|
{
|
|
|
|
$this->setDescription('Import Destination Data Events');
|
|
|
|
$this->setHelp('Destination Data Events are imported');
|
|
|
|
|
|
|
|
$this->addArgument(
|
|
|
|
'storage-pid',
|
2021-12-14 16:22:29 +01:00
|
|
|
InputArgument::REQUIRED,
|
|
|
|
'What is the storage pid?'
|
2019-08-12 07:43:37 +02:00
|
|
|
);
|
2021-01-07 08:50:43 +01:00
|
|
|
$this->addArgument(
|
|
|
|
'rest-experience',
|
2021-12-14 16:22:29 +01:00
|
|
|
InputArgument::REQUIRED,
|
|
|
|
'What is the rest experience?'
|
2019-08-12 07:43:37 +02:00
|
|
|
);
|
2021-01-07 08:50:43 +01:00
|
|
|
$this->addArgument(
|
|
|
|
'files-folder',
|
2021-12-14 16:22:29 +01:00
|
|
|
InputArgument::REQUIRED,
|
|
|
|
'Where to save the image files?'
|
2019-08-12 07:43:37 +02:00
|
|
|
);
|
2021-12-15 12:28:06 +01:00
|
|
|
$this->addArgument(
|
|
|
|
'region-uid',
|
|
|
|
InputArgument::OPTIONAL,
|
|
|
|
'What is the region uid?'
|
|
|
|
);
|
2022-01-26 14:43:14 +01:00
|
|
|
$this->addArgument(
|
|
|
|
'query',
|
|
|
|
InputArgument::OPTIONAL,
|
|
|
|
'What is the additional query "q" parameter?'
|
|
|
|
);
|
2019-08-12 07:43:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
Bootstrap::initializeBackendAuthentication();
|
|
|
|
|
2021-12-16 14:34:17 +01:00
|
|
|
$regionUid = $input->getArgument('region-uid');
|
|
|
|
if (is_numeric($regionUid)) {
|
|
|
|
$regionUid = (int) $regionUid;
|
|
|
|
} else {
|
|
|
|
$regionUid = null;
|
|
|
|
}
|
|
|
|
|
2022-01-26 14:43:14 +01:00
|
|
|
$query = $input->getArgument('query');
|
|
|
|
if (is_string($query) === false) {
|
|
|
|
$query = '';
|
|
|
|
}
|
|
|
|
|
2022-01-27 14:14:02 +01:00
|
|
|
$import = $this->importFactory->createFromArray([
|
|
|
|
'storage_pid' => $input->getArgument('storage-pid'),
|
|
|
|
|
|
|
|
'files_folder' => $input->getArgument('files-folder'),
|
|
|
|
|
|
|
|
'region_uid' => $regionUid,
|
|
|
|
|
|
|
|
'rest_experience' => $input->getArgument('rest-experience'),
|
|
|
|
'rest_search_query' => $query,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return $this->destinationDataImportService->import(
|
|
|
|
$import
|
|
|
|
);
|
2019-08-12 07:43:37 +02:00
|
|
|
}
|
2021-01-07 08:50:43 +01:00
|
|
|
}
|