Skip to content

Commit 81e1039

Browse files
committed
fix import-async command
1 parent c54ed4d commit 81e1039

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/DataDefinitionsBundle/Command/ImportAsyncCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,23 @@ protected function configure(): void
5959
protected function execute(InputInterface $input, OutputInterface $output)
6060
{
6161
$params = json_decode($input->getOption('params'), true);
62+
$definitionId = $input->getOption('definition');
6263

6364
if (!isset($params['userId'])) {
6465
$params['userId'] = 0;
6566
}
6667

6768
try {
68-
$definition = $this->repository->find($input->getOption('definition'));
69-
} catch (InvalidArgumentException $e) {
70-
$definition = $this->repository->findByName($input->getOption('definition'));
69+
if (filter_var($definitionId, \FILTER_VALIDATE_INT)) {
70+
$definition = $this->repository->find($definitionId);
71+
} else {
72+
$definition = $this->repository->findByName($definitionId);
73+
}
74+
} catch (NotFoundException) {
7175
}
7276

7377
if (!$definition instanceof ImportDefinitionInterface) {
74-
throw new Exception('Import Definition not found');
78+
throw new Exception(sprintf('Import Definition with ID/Name "%s" not found', $definitionId));
7579
}
7680

7781
$this->importer->doImportAsync($definition, $params);

0 commit comments

Comments
 (0)