Closed LouisGarret closed 1 year ago
Ok I've found a solution, adding this in all my command
public function configureParallelExecutableFactory(
ParallelExecutorFactory $parallelExecutorFactory,
InputInterface $input,
OutputInterface $output
): ParallelExecutorFactory {
return parent::configureParallelExecutableFactory(
$parallelExecutorFactory,
$input,
$output
)->withRunBeforeFirstCommand(fn () => $this->runBeforeFirstCommand($input, $output));
}
Why did you move that to hooks ? It's not used frequently ?
Sorry for the late reply.
Why did you move that to hooks ? It's not used frequently ?
It's not rare, but not super common neither.
Regarding your sample there is a mistake, it should be:
public function configureParallelExecutableFactory(
ParallelExecutorFactory $parallelExecutorFactory,
InputInterface $input,
OutputInterface $output
): ParallelExecutorFactory {
// You can skip calling the parent here. If you check the parent implementation it is just a placeholder
// very much like the Symfony `Command::interact()` or others.
return $parallelExecutorFactory
// The callable gets its own input/output, as it might differ from the current ones
->withRunBeforeFirxstCommand(fn ($input, $output) => $this->runBeforeFirstCommand($input, $output));
// Alternatively if you are on PHP 8.1 and do not inject any extra data to your runBeforeFirstCommand() implementation:
->withRunBeforeFirxstCommand($this->runBeforeFirstCommand(...));
}
Edit: there actually is configureParallelExecutableFactory()
which works better
Hello,
Is it possible to provide documentation for using the
::getParallelExecutableFactory
?It's not clear, and I don't understand how to use it, I have many command using the runBeforeFirstCommand function before the upgrade.
Regards, Louis