Problem/Motivation
Split from #2015121: Inject various dependencies into DisplayPluginBase. Using a service locator model to inject views plugin managers in the views display plugin classes was proposed in #52 and #59
there. This issue is to introduce the service locator and deprecate the Views::pluginManager() and Views::handerManager() methods.
Steps to reproduce
Proposed resolution
See MR!14258 from #2015121: Inject various dependencies into DisplayPluginBase as reference for implementing the service locator.
The deprecate Views::pluginManager() and Views::handerManager() by replacing the use of Drupal::service() with service locator instead and triggering the appropriate deprecations.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3566424
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:
- 3566424-deprecate-viewspluginmanager-and
changes, plain diff MR !14274
Comments
Comment #4
longwaveUnsure if we should trigger deprecations or not yet.
Comment #5
godotislateA quick search shows 34 uses of pluginManager() and 9 uses of handlerManager() in core. Haven't looked closely, but I'm guessing more than a few uses aren't easily injectable, so maybe we defer deprecation.
Comment #6
longwaveWe could bulk replace existing uses with
\Drupal::service('views.plugin_managers')(or the specific manager for static cases), which would start us down that road I suppose.Comment #7
godotislateThat sounds good to me.
Comment #8
longwaveConverted existing uses and added a test.
Disclaimer: parts of this MR were assisted by Claude Code.
Comment #9
godotislateThis needs a CR for the deprecation, so tagging for that. The MR will need to be updated with the CR URL once avaiable.
Also tagging 'Needs followup' for issue(s) to dependency inject the service locator or specific views plugin managers wherever possible.
MR otherwise looks good.
Comment #10
longwaveAdded CR and updated the link: https://www.drupal.org/node/3566982
Comment #11
godotislateCR and MR lgtm.
Comment #13
catchCommitted/pushed to main and 11.x, thanks!
Comment #17
mondrakeThis added two instances of
#[Group('legacy')]attribute usage in ViewsTest, that are not correct: https://www.drupal.org/node/3447698Will be fixed in #3497124: Deprecate expectDeprecation(), use PHPUnit's expectUserDeprecationMessage*() instead.
Comment #18
joelpittetWhat's the best way to support D10 onward with this kinda change? Is that something we can add as an addendum to the CR?Edit ignore me...Sorry, I guess in D10 support I can just go with:
Was looking at the code and it's just a wrapper.