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:Listener] Improve event name matching #1410

Open
maelanleborgne opened this issue Dec 15, 2023 · 1 comment
Open

[Make:Listener] Improve event name matching #1410

maelanleborgne opened this issue Dec 15, 2023 · 1 comment

Comments

@maelanleborgne
Copy link
Contributor

Description

When using a class's FQCN as event name, you have to enter the FQCN in the command to make it work.

If the event name given by the user doesn't match a registered event name nor an FQCN, we could try to 'guess' if the input matches a class short name from the App\\ namespace (we could even sneak some levenshtein in there to catch typos) and ask if the user meant one of the matching results.

Do you think that would be doable without ruining the performance (I imagine that on large projects with a lot of classes that could be a rather heavy process) ?

Example

Choose a class name for your event listener or subscriber (e.g. ExceptionListener or ExceptionSubscriber):
 > CustomEventListener

What event do you want to listen to?:
 > MyCustomEvent

Did you mean ... [MyCustomEvent]
[0] MyCustomEvent
[1] App\Event\MyCustomEvent
 > App\Event\MyCustomEvent  # <- Here we would have auto-completion from the suggestions above
@maelanleborgne
Copy link
Contributor Author

@weaverryan What do you think of this idea ? I started some work on this feature but to list all events, we need to force the declaration of all the classes that extend the Event base class,. I couldn't find a clean way to achieve this.

Maybe just matching on the built-in events (that we can access from the event registry) would be enough ?

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

No branches or pull requests

1 participant