-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
[make:subscriber] Improve MakeSubscriber to use KernelEvents constant instead hardcoded event #940
Conversation
8710e97
to
1dfe5d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the approach - minor comments, and we need a test!
Also, in the interactive list that we show the users (when asking for which event they want), do we show the string name kernel.controller
or the class name - ControllerEvent
? We should probably show the class name.
1130313
to
37aec4e
Compare
$eventName = $eventConstant; | ||
} else { | ||
$eventName = class_exists($event) ? sprintf('%s::class', $eventClassName) : sprintf('\'%s\'', $event); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could move $eventFullClassName
and $eventClassName
into this else. And also move the $useStatements->addUseStatement($eventFullClassName);
into this as well. It's all just a bit spread out right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can without adding more noise.. we have to handle a custom event like \Symfony\MakerBundle\Generator::class
and assert that we subscribe to Generator::class => onGenerator
. Side note - just added a testcase for this situation
Use KernelEvents constant instead hardcoded event type in MakeSubscriber.
#744