-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI][FrameworkBundle] (Idea) PHP-DSL base class for simple shortcuts for DI #27073
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
Comments
We already have autoconfiguration being able to identifier event subscribers and doctrine repositories (and controllers when they extend the base class). So what would be the benefit of these shortcuts when the minimal code needed in all of them is to register the service ? |
Hmm, haven't heard about identifying doctrine repositories, cause all the time you need to define repo as a service via factory if you want to inject it... The key point of this idea is to minimize repetitive code when working on big projects, so for e.g. Instead of writing 5 lines of code every time you need to define repository as a service. P.S. I think autoconfiguration identifier doesn't work with out of src folder code for e.g. If the application is designed to be modular. |
As @stof, I'm not sure this would provide many benefits over the current way to express the same. It would also be for sure much more restrictive. BUT, that could instead be a great start to implement per bundle PHP-DSL-style configuration, instead of the current
Yes it does: autoconfiguration works where you configure it. Can be anywhere. |
Look at the new features of DoctrineBundle 1.8 about that: doctrine/DoctrineBundle#727 Registering the Doctrine repository as a service without this feature is a very bad idea, as it breaks the entity manager resetting (your service keeps using the old entity manager). And with this feature, it can be autoconfigured. |
Closing this issue as it didn't get traction. |
Hi,
Thanks for merging my PR #27065 my whole point of that change was to ability use inline classes with
__invoke
method and some shortcuts likeaddCommand
,addService
,addControllers
,addRepository
.So I thought about something a bit wider scope for e.g. Make a base class inside FrameworkBundle which would have all shortcuts for main features and would allow extending default properties of it and etc.
Something like this:
Either way, I am going to make it either an external library or try to integrate inside FrameworkBundle. But I just don't know all shortcuts I should add and if someone could suggest more these kind of shortcuts I would not mind spending time implementing this util class.
The text was updated successfully, but these errors were encountered: