-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface #20260
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
[DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface #20260
Conversation
89de71d
to
5a47ec7
Compare
The Status: needs work |
The If we want to make this PR work properly with the event dispatcher in debug mode, we should transfer the |
29dbb87
to
cd003a0
Compare
@ogizanagi As you suggested, I made The However we still need to manually cleanup the Anyway, that's really not a big deal (one method call on the definition). |
da8fb14
to
d7ca505
Compare
Failing build on travis unrelated (yaml) |
It's kind of a big deal. 😄 I thought 71d502a was supposed to handle this case 😕 |
Needs #20267 for removing this method call. |
2c0636b
to
3acbff9
Compare
<argument type="service" id="debug.stopwatch" /> | ||
<argument type="service" id="logger" on-invalid="null" /> | ||
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcherInterface</autowiring-type> | ||
<autowiring-type>Symfony\Component\EventDispatcher\EventDispatcher</autowiring-type> |
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.
This will not be needed with #20267 too
…the autowiring types (chalasr) This PR was merged into the 2.8 branch. Discussion ---------- [DependencyInjection] A decorated service should not keep the autowiring types | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20260 (comment) | License | MIT | Doc PR | n/a When decorating a service which is not abstract and has `autowiring_types`, the decorator should be the one used for autowiring methods of autowired services, so we should explicitly empty them on the decorated definition after merged them into the child. See #20260 (comment) for a use case where we are forced to manually empty the decorated service's `autowiring_types`. Commits ------- 5951378 A decorated service should not keep the autowiring types
…the autowiring types (chalasr) This PR was merged into the 2.8 branch. Discussion ---------- [DependencyInjection] A decorated service should not keep the autowiring types | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony#20260 (comment) | License | MIT | Doc PR | n/a When decorating a service which is not abstract and has `autowiring_types`, the decorator should be the one used for autowiring methods of autowired services, so we should explicitly empty them on the decorated definition after merged them into the child. See symfony/symfony#20260 (comment) for a use case where we are forced to manually empty the decorated service's `autowiring_types`. Commits ------- 5951378 A decorated service should not keep the autowiring types
Needs branch 2.8 to be merged in master |
3acbff9
to
3c6c488
Compare
I made the changes after #20267, this is ready. |
3c6c488
to
d2d68dd
Compare
7ce69e0
to
e25dd2f
Compare
Tests have been fixed. |
👍 Status: Reviewed |
@dunglas could you please review/approve this proposal? Do you think it's ready for 3.2? Thanks! |
👍 For me it's ok to merge this PR in 3.2. |
e25dd2f
to
5fd4733
Compare
apparently it will finally be for 3.3 as many others, it would be nice to have an explanation. |
End of development happened more than a month and a half ago. Since then, we should not have merged new features or significant changes. We did some for features that were discussion since a very long time, but we had priorities. RC1 is just around the corner, so merging anything substantial at this point is not possible anymore. Sorry about that, but we need to make choices. That's our release process. Date is fixed, features are not. |
And I can perfectly understand, thank you for the hint. |
I believe this can be merged now that 3.2 is released. |
Thank you @chalasr. |
…atcher/EventDispatcherInterface (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | n/a | | License | MIT | | Doc PR | n/a | As it is a very common dependency. Currently it gives: > [Symfony\Component\DependencyInjection\Exception\RuntimeException] > Unable to autowire argument of type "Symfony\Component\EventDispatcher\EventDispatcherInterface" for the service "dummy". Multiple services exist for this interface (debug.event_dispatcher, debug.event_dispatcher.parent). After this, the `TraceableEventDispatcher` will be injected in dev and the `ContainerAwareEventDispatcher` in prod, as when injecting `@event_dispatcher` explicitly. ping @weaverryan IMHO this could be treated as a an enhancement for the autowiring feature and be part of 3.2. Commits ------- 5fd4733 Support autowiring for EventDispatcher/EventDispatcherInterface
…entDispatcher/EventDispatcherInterface (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | n/a | | License | MIT | | Doc PR | n/a | As it is a very common dependency. Currently it gives: > [Symfony\Component\DependencyInjection\Exception\RuntimeException] > Unable to autowire argument of type "Symfony\Component\EventDispatcher\EventDispatcherInterface" for the service "dummy". Multiple services exist for this interface (debug.event_dispatcher, debug.event_dispatcher.parent). After this, the `TraceableEventDispatcher` will be injected in dev and the `ContainerAwareEventDispatcher` in prod, as when injecting `@event_dispatcher` explicitly. ping @weaverryan IMHO this could be treated as a an enhancement for the autowiring feature and be part of 3.2. Commits ------- 5fd4733 Support autowiring for EventDispatcher/EventDispatcherInterface
…entDispatcher/EventDispatcherInterface (chalasr) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] Support autowiring for EventDispatcher/EventDispatcherInterface | Q | A | | --- | --- | | Branch? | master | | Bug fix? | no | | New feature? | yes | | BC breaks? | no | | Deprecations? | no | | Tests pass? | yes | | Fixed tickets | n/a | | License | MIT | | Doc PR | n/a | As it is a very common dependency. Currently it gives: > [Symfony\Component\DependencyInjection\Exception\RuntimeException] > Unable to autowire argument of type "Symfony\Component\EventDispatcher\EventDispatcherInterface" for the service "dummy". Multiple services exist for this interface (debug.event_dispatcher, debug.event_dispatcher.parent). After this, the `TraceableEventDispatcher` will be injected in dev and the `ContainerAwareEventDispatcher` in prod, as when injecting `@event_dispatcher` explicitly. ping @weaverryan IMHO this could be treated as a an enhancement for the autowiring feature and be part of 3.2. Commits ------- 5fd4733 Support autowiring for EventDispatcher/EventDispatcherInterface
As it is a very common dependency. Currently it gives:
After this, the
TraceableEventDispatcher
will be injected in dev and theContainerAwareEventDispatcher
in prod, as when injecting@event_dispatcher
explicitly.ping @weaverryan
IMHO this could be treated as a an enhancement for the autowiring feature and be part of 3.2.