Currently blocked by:
- #2941757: Extension System, Part IV: Properly register all installed extensions/namespaces during container generation
- #3023131: [PP-1] Extension System, Part IV: ExtensionHandler and ExtensionHandlerInterface
Problem/Motivation
The DefaultPluginMananger, by default, limits plugin discovery within modules only.
This is partially due to #2941757: Extension System, Part IV: Properly register all installed extensions/namespaces during container generation, but also a byproduct of simply creating a new API/system in core knowing that not all real-world scenarios or use cases would be fully realized.
We now know that plugin managers need better control over the specificity in what and how they discover plugins.
Workarounds in contrib result in some rather "hackish" ways just so that themes can be included in plugin discoverability:
http://cgit.drupalcode.org/bootstrap/tree/src/Plugin/PluginManager.php
http://cgit.drupalcode.org/bootstrap_layouts/tree/src/BootstrapLayoutsPl...
Instead of using the arbitrary "namespaces", we should use "provider" based plugin manager that allows both core and contrib alike to specify exactly which providers should be allowed in their discovery.
Yes, there are instances where plugin discovery should be limited to a single provider (@Block -> modules, @Theme -> themes) . However, in most cases, this limitation is unnecessary.
There is also the problem of the current providerExists() method, in which it defaults to checking the ModuleHandler. By abstracting the providers (and their relevant services) into their own objects/services, we can more easily and correctly determine if the provider actually exists.
Proposed resolution
Introduce the concept of plugin "providers" which allows core and contrib plugin managers to extend from.
Example in contrib:
https://cgit.drupalcode.org/plus/tree/plus.services.yml?h=8.x-4.x
https://cgit.drupalcode.org/plus/tree/src/ProviderPluginManager.php?h=8....
https://cgit.drupalcode.org/plus/tree/src/Plugin/BasePluginProviderType....
https://cgit.drupalcode.org/plus/tree/src/Plugin/ChainedPluginProviderTy...
https://cgit.drupalcode.org/plus/tree/src/Plugin/ModulePluginProviderTyp...
https://cgit.drupalcode.org/plus/tree/src/Plugin/ProfilePluginProviderTy...
https://cgit.drupalcode.org/plus/tree/src/Plugin/ThemePluginProviderType...
Remaining tasks
- Create patch
- Create tests
User interface changes
None
API changes
No changes, just an addition.
Data model changes
None
Comments
Comment #2
markhalliwellComment #3
markhalliwellComment #5
markhalliwellBoth "provider" and "types" really mean the same thing and is redundant to put them together.
Comment #6
markhalliwellAlso postponed on this issue.
Comment #8
mr.baileys