Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix parsed input arguments for command events using dispatcher rerouting #46442

Merged
merged 5 commits into from
Mar 13, 2023

Conversation

bert-w
Copy link
Contributor

@bert-w bert-w commented Mar 12, 2023

This is a draft PR for #46430 where a Symfony dispatcher is created for \Illuminate\Console\Application in order to reroute the events to the Laravel counterpart. This has the benefit that the Input is properly bound to the command definition, and it is thus available in the event itself.

The complete \Illuminate\Console\Application::run() override has been removed.

This opens up the possibility to add some more events as well:

  • \Symfony\Component\Console\ConsoleEvents::COMMAND
    • (Laravel's version: \Illuminate\Console\Events\CommandStarting, included in PR)
  • \Symfony\Component\ConsoleConsoleEvents::TERMINATE
    • (Laravel's version: \Illuminate\Console\Events\CommandFinished, included in PR)
  • \Symfony\Component\Console\ConsoleEvents::SIGNAL
    • (no Laravel version yet)
  • \Symfony\Component\Console\ConsoleEvents::ERROR
    • (no Laravel version yet)

$dispatcher = new EventDispatcher();
$this->setDispatcher($dispatcher);

$dispatcher->addListener(ConsoleEvents::COMMAND, function (ConsoleCommandEvent $event) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optionally this can be changed to $dispatcher->addSubscriber(...) and move this logic to a separate class

@taylorotwell taylorotwell marked this pull request as ready for review March 13, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants