Problem/Motivation
In #3049525: Enable service autowiring by adding interface aliases to core service definitions we enabled core.services.yml for autowiring by adding aliases to several core interfaces and classes. We can extend this by doing the same for core modules.
Steps to reproduce
Proposed resolution
Extend AutowireTest to cover core modules as well as core.services.yml.
Add aliases to module interfaces and classes where appropriate.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|
Issue fork drupal-3325557
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
longwaveComment #5
longwaveComment #7
longwaveCrediting @kim.pepper for review, thanks for spotting that; back to NR.
Removing credit for @Rajeshreeputra for an unnecessary reroll.
Comment #8
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #9
longwaveComment #10
mondrakeLooks good to me. RTBC.
Going OT a bit: how about https://symfony.com/doc/current/service_container/autowiring.html#dealin...? This would help autowiring for cache bins and for loggers like e.g.
Comment #11
longwaveThanks. Not sure yet what approach would work for cache bins (feel free to open a followup!), but for loggers I think binding a default per module could work, see #3295542-3: Use logger channel services consistently, instead of the factory object.
Comment #12
mondrakeNeeds rebasing
Comment #13
longwaveRebased, back to RTBC.
Comment #15
Amber Himes Matz1. Looks like there is 1 unresolved comment (that got addressed but was never marked as resolved): https://git.drupalcode.org/project/drupal/-/merge_requests/3075#note_137045)
2. The merge request is currently blocked and needs a rebase.
Thank you!
Comment #16
longwaveRebased and resolved the comment, back to RTBC.
Comment #17
catchA lot of these services are ones I would never expect to be used outside the module. This issue doesn't really make that any more or less the case but wondering if we really want to do this for every service in core.
Comment #18
longwave@catch the followup to this is #3295751: Autowire core services that do not require explicit configuration where we can start using autowiring for real across core, and don't have to specify exact arguments any more for a large number of service definitions. Even when the aliases are only used within a module, adding the alias allows autowiring within that module, or by anything that wants to inject the aliased service in contrib/custom code.
Comment #19
catchOh I didn't think about within the module itself... makes sense then.
Committed/pushed to 11.x (10.2.x), thanks!
Comment #21
mondrakeFiled #3367416: [policy] Service autowiring - decide approach for multiple service implementations based on the same class and different arguments as a possible followup.
Comment #23
andypostIt needs follow-up according to #3354584-14: Deprecate TrustedCallbackInterface in favour of TrustedCallback attribute
some classes that used to implement interface now brings false positive
Comment #24
joachim CreditAttribution: joachim commentedThis needs a CR to say that most core services need an interface alias.
The test assertion and test docs also needs more detail, otherwise adding a new service to core just gets you this confusing test failure and you're left doing git archeology to find this issue :(
Comment #25
andypostWe could use #3392396: Improve AutowireTest to ignore TrustedCallbackInterface for that