Skip to content

Commit 6713d76

Browse files
sezagxaviermarchegay
authored andcommitted
Check process code before process execution registering
1 parent e823b6a commit 6713d76

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Command/ExecuteProcessCommand.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use CleverAge\ProcessBundle\Event\ConsoleProcessEvent;
1717
use CleverAge\ProcessBundle\Filesystem\JsonStreamFile;
1818
use CleverAge\ProcessBundle\Manager\ProcessManager;
19+
use CleverAge\ProcessBundle\Registry\ProcessConfigurationRegistry;
1920
use Psr\EventDispatcher\EventDispatcherInterface;
21+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
2022
use Symfony\Component\Console\Attribute\AsCommand;
2123
use Symfony\Component\Console\Command\Command;
2224
use Symfony\Component\Console\Input\InputArgument;
@@ -40,7 +42,8 @@ class ExecuteProcessCommand extends Command
4042

4143
public function __construct(
4244
protected ProcessManager $processManager,
43-
protected EventDispatcherInterface $eventDispatcher
45+
protected EventDispatcherInterface $eventDispatcher,
46+
protected ProcessConfigurationRegistry $processRegistry,
4447
) {
4548
parent::__construct();
4649
}
@@ -86,6 +89,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8689
$this->eventDispatcher->dispatch(new ConsoleProcessEvent($input, $output, $inputData, $context));
8790

8891
foreach ($input->getArgument('processCodes') as $code) {
92+
if (!$this->processRegistry->hasProcessConfiguration($code)) {
93+
throw new InvalidConfigurationException("Unknown process {$code}");
94+
}
95+
8996
if (!$output->isQuiet()) {
9097
$output->writeln("<comment>Starting process '{$code}'...</comment>");
9198
}

0 commit comments

Comments
 (0)