-
Notifications
You must be signed in to change notification settings - Fork 43
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
RFC: Autowiring commands to handlers in Symfony 3.3+ #44
Comments
It'd be great if it's also flexible enough & configurable out of the box. E.g: |
IMO everyone have its own habits regarding stuff naming. As @ogizanagi said we need this very flexible to be used. In our apps, we have not dedicated handlers for example, so it becomes difficult to make magic I guess ;) |
Note that in the yaml configuration shown in the description: services:
App\:
resource: '../../src/{Handler}'
tags: ['tactician.handler'] the tag could also be completely removed if we introduce a marker interface, thanks to the autoconfigure capabilities of sf 3.3. A similar marker is under discussion for Twig runtimes, which currently don't have any interface either. |
This is the tough one. In my project we use notation like this:
Sounds great, with a few most popular implementations it can work really well. If you need any help, I would be glad to. |
If we add an handler interface maybe we could add a static method to it that returns the corresponding command to remove the need for an inflector. |
We've experimented with marker interfaces in the early days of Tactician
and it never really worked out, so they were removed and won't return in
core, especially since a large number of folks will probably never use
autowiring.
That said, if folks want to build it themselves, I think we should make it
possible for them. (it's already possible today by writing a custom
HandlerLocator which isn't super hard)
…On Jun 3, 2017 3:01 PM, "Jérôme" ***@***.***> wrote:
If me add an handler interface maybe we could add a static method to it
that gives the corresponding command to remove the need for an inflector.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#44 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAI9TtxaBo32WT4lSoPdSPOb97LqVRD3ks5sAVkogaJpZM4Nol_P>
.
|
I think it's slightly different here. No need to be in the core. It'll only serve autoconfiguring purpose, which is a symfony thing, thus should only be in the bundle. This marker interface should not serve any other means. |
Besides, using a marker interface could be the best way to differentiate who wants to use autowiring or not. |
Based on the new service discovery coming in Symfony 3.3, I'd like to add a naming convention based locator.
The idea is that we could use config like:
This would autowire all handlers into the DI container using their FQCN as service id (RegisterUserHandler).
The proposed new locator would automatically route a command with a FQCN like Foo\RegisterUser or Foo\RegisterUserCommand to Foo\RegisterUserHandler. We could pull that directly from the container/service locator and presto, it works.
Pros:
Cons:
Thoughts:
While I'm only so-so on autowiring containers and generally avoid it, I think this is a feature that pro-autowiring folks would really enjoy.
Thoughts? Totally open to all config format/feature/implementation suggestions here. :)
The text was updated successfully, but these errors were encountered: