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

[make:subscriber] Improve MakeSubscriber to use KernelEvents constant instead hardcoded event #940

Merged
merged 10 commits into from
Jul 13, 2022

Conversation

bdaler
Copy link
Contributor

@bdaler bdaler commented Aug 10, 2021

Use KernelEvents constant instead hardcoded event type in MakeSubscriber.
#744

@jrushlow jrushlow added the Feature New Feature label Mar 3, 2022
Copy link
Member

@weaverryan weaverryan left a 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.

src/Maker/MakeSubscriber.php Show resolved Hide resolved
src/Maker/MakeSubscriber.php Outdated Show resolved Hide resolved
src/Maker/MakeSubscriber.php Outdated Show resolved Hide resolved
@jrushlow
Copy link
Collaborator

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.

This is what we have -
image

Seems like the best of both worlds

@jrushlow jrushlow added the Status: Needs Review Needs to be reviewed label Jul 12, 2022
$eventName = $eventConstant;
} else {
$eventName = class_exists($event) ? sprintf('%s::class', $eventClassName) : sprintf('\'%s\'', $event);
}
Copy link
Member

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.

Copy link
Collaborator

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

src/Maker/MakeSubscriber.php Outdated Show resolved Hide resolved
@weaverryan
Copy link
Member

Thanks @bdaler and @jrushlow!

@weaverryan weaverryan merged commit 8a3de03 into symfony:main Jul 13, 2022
@jrushlow jrushlow mentioned this pull request Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants