2022-01-27 14:14:02 +01:00
|
|
|
<?php
|
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Command;
|
2022-01-27 14:14:02 +01:00
|
|
|
|
2023-11-27 10:04:42 +01:00
|
|
|
use Exception;
|
2022-01-27 14:14:02 +01:00
|
|
|
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;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\DestinationData\ImportFactory;
|
|
|
|
use WerkraumMedia\Events\Service\DestinationDataImportService;
|
2022-01-27 14:14:02 +01:00
|
|
|
|
|
|
|
class ImportDestinationDataViaConfigruationCommand extends Command
|
|
|
|
{
|
|
|
|
public function __construct(
|
2023-11-27 10:04:42 +01:00
|
|
|
private readonly DestinationDataImportService $destinationDataImportService,
|
|
|
|
private readonly ImportFactory $importFactory
|
2022-01-27 14:14:02 +01:00
|
|
|
) {
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function configure(): void
|
|
|
|
{
|
|
|
|
$this->setDescription('Import Destination Data Events');
|
|
|
|
$this->setHelp('Destination Data Events are imported from given configuration record.');
|
|
|
|
|
|
|
|
$this->addArgument(
|
|
|
|
'configurationUid',
|
|
|
|
InputArgument::REQUIRED,
|
|
|
|
'UID of the configuration to import'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
Bootstrap::initializeBackendAuthentication();
|
|
|
|
|
|
|
|
$configurationUid = $input->getArgument('configurationUid');
|
|
|
|
if (is_numeric($configurationUid)) {
|
2023-06-07 08:56:42 +02:00
|
|
|
$configurationUid = (int)$configurationUid;
|
2022-01-27 14:14:02 +01:00
|
|
|
} else {
|
2023-11-27 10:04:42 +01:00
|
|
|
throw new Exception('No numeric uid for configuration provided.', 1643267138);
|
2022-01-27 14:14:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$import = $this->importFactory->createFromUid(
|
|
|
|
$configurationUid
|
|
|
|
);
|
|
|
|
return $this->destinationDataImportService->import(
|
|
|
|
$import
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|