Problem/Motivation
Not all installed extensions, and their respective namespaces, are properly registered within the container.
This issue is, primarily, relevant to themes and theme engines as modules and profiles are currently hardcoded.
Certain requests only bootstrap so far. If a theme provides a static callback (in the form of #pre_render
, #ajax
, or #lazy_builder
) to a method in one of its classes, this lives in a render array which can become cached. Because of this caching, the entire theme system does not necessarily need to be loaded just to execute a callback. Thus, the namespaces are never registered and the classes cannot be found.
It is a common misnomer that extension namespaces are registered on install.
Currently, the ThemeExtensionList is what instantiates and registers all installed theme namespaces.
DrupalKernel::compileContainer automatically registers module namespaces, simply because they can provide services (since themes cannot). However, these namespaces are done after the service providers have been determined and effectively cut all other installed extension types out of being properly registered.
There are also no significant tests to ensure that these namespaces are registered properly and whether or not they would in fact break contrib.
Proposed resolution
Register all installed extensions and their namespaces as separate container parameters:
container.namespaces.core
- Drupal specific ['Core', 'Component']
namespaces.
container.namespaces.module
container.namespaces.profile
container.namespaces.theme
container.namespaces.theme_engine
container.namespaces.all
- all of the above namespaces
For BC reasons, the existing container.namespaces
parameter/service needs to be aliased to the following namespaces:
container.namespaces.core
container.namespaces.module
container.namespaces.profile
And then deprecate the use of container.namespaces
when
#2954562: [PP-2] Create provider based plugin managers β
makes it way in to allow plugin managers to choose which namespaces to allow.
Remaining tasks
- Create tests
- Create a patch
User interface changes
None
API changes
- Adds new service:
- Adds new parameters:
container.namespaces.core
- Drupal specific ['Core', 'Component']
namespaces.
container.namespaces.module
container.namespaces.profile
container.namespaces.theme
container.namespaces.theme_engine
container.namespaces.all
- all of the above namespaces
Data model changes
None