Allow experimental modules to rely on \Drupal\Core\ namespaced classes that are only loadable when the module is enabled

Created on 6 December 2016, over 8 years ago
Updated 8 June 2025, about 1 month ago

Problem/Motivation

#2296423: Implement layout plugin type in core and #2779647: Add a workflow component, ui module, and implement it in content moderation are both adding experimental code to core/lib. There have been a number of concerns raised about this on the issues. For example, #2296423-150: Implement layout plugin type in core and #2296423-158: Implement layout plugin type in core

One of the main concerns is that code in core/lib is always available and modules that use it might not necessarily have the same level of warnings to the user as an experimental module. Another important concern is that experiments have to be uninstallable and not break sites. Once code is in core/lib it is tricky to guarantee this.

On the other hand, moving code from an experimental module to core/lib once it is mature means all the contrib / other modules that experimented with it have to be updated.

This is a major task because being able to add experimental APIs to core is a key task to ensure that Drupal 8 can experiment and look to provide as continuous an upgrade path to D9 as possible.

Proposed resolution

Whilst discussing this issue with @catch, @xjm, @dries, @effulgentsia, @cilefen and @webchick I realised that we could use the autoloader to fix this for us. The namespaces of the code would still be \Drupal\Core\NewThing but the location of the files would be core/experimental. In order to enable autoloading of the files you would need to install an experimental module that adds the ability for Drupal to autoload this code.

Remaining tasks

User interface changes

None

API changes

An API for experimental modules to add classes in core/experimental to the autoloader.

Data model changes

None

📌 Task
Status

Needs work

Version

11.0 🔥

Component

extension system

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024