You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console Event ConsoleEvents::COMMAND doesn't provide any way to read/modify input arguments/options before command is ran. It's because binding code (argument string to command arguments/options) is within $command->run($input, $output); method itself.
publicfunctiononCommandExecution(ConsoleCommandEvent$event)
{
$command = $event->getCommand();
if ($commandinstanceof GameAwareCommand) { // this apply only to certain commands implementing interface/** @var \Symfony\Bundle\FrameworkBundle\Console\Application $application */$application = $command->getApplication();
/** @var ArgvInput $input */$input = $event->getInput();
/** @var Command $command */$command->getDefinition();
$input->getArguments(); // empty array$input->getOptions(); // empty array
}
}
Input instance returned by $event->getInput() is pretty much useless because it's empty (at least through public methods).
The best would be to dispatch additional event after parsing and binding but before running, this was already discussed few times e.g. here #11384 and it's not something we could do before 3.0
Do you have opinion about this? I need this feature to read input value before command execution so I'm willing to make proper contribution once I get some feedback about the best approach. Thanks
The text was updated successfully, but these errors were encountered:
Console Event
ConsoleEvents::COMMAND
doesn't provide any way to read/modify input arguments/options before command is ran. It's because binding code (argument string to command arguments/options) is within$command->run($input, $output);
method itself.Input instance returned by $event->getInput() is pretty much useless because it's empty (at least through public methods).
The best would be to dispatch additional event after parsing and binding but before running, this was already discussed few times e.g. here #11384 and it's not something we could do before 3.0
Do you have opinion about this? I need this feature to read input value before command execution so I'm willing to make proper contribution once I get some feedback about the best approach. Thanks
The text was updated successfully, but these errors were encountered: