Allow overrides just how Drupal Core's Configuration override system works

Created on 12 January 2023, over 1 year ago
Updated 22 February 2024, 4 months ago

Background

An important usecase of Config Pages is to make it easier to create configuration pages during site development.
And it does that very well.

But because it is build with the a Drupal content entity, it doesn't allow for overriding values in settings.php.
This would be a handy feature.

Problem

Imagine that Config Pages is used to create configuration for functionality with "feature flags". An example would be:
* checkbox enable feature "Display cookie banner popup to all users" = TRUE / FALSE
* cookie banner title: text field
* cookie banner body: text field

Now we want to enable this on all environments, except a local development environment.
With Drupal Core's Configuration override system ( https://www.drupal.org/docs/drupal-apis/configuration-api/configuration-... β†’ ) one would add the following snippet to settings.php (pseudo code):
$config['config_pages.custom_cookie_banner']['feature_flag_enabled'] = FALSE

Which then would override the configuration.

Proposed resolution

Idea 1:
When values are loading via the api of config_pages like this ConfigPages::config('custom_cookie_banner')->get('feature_flag_enabled');,
check for the pattern $config['config_pages.custom_cookie_banner']['feature_flag_enabled'] via Drupal Core's config system.
If the latter has a value, return that overridden value.

Add a optional parameter to the ->get() method to not include overrides. I.e.:
ConfigPages::config('custom_cookie_banner')->get('feature_flag_enabled', TRUE); will load the original stored value.

Idea 2:
Allow loading of config_pages via Drupal core's config system. I.e. when using \Drupal::config('config_pages.custom_cookie_banner')->get('feature_flag_enabled'); returns the value stored in the content-entity of ConfigPages. (this might be technically impossible due to the inner workings of the config and content APIs, but I propose this as idea).
Validate that overriding behaves the same as Drupal core's way.
NB this could also have unwanted side effects with exporting and importing of configuration.

✨ Feature request
Status

Active

Version

3.0

Component

User interface

Created by

πŸ‡³πŸ‡±Netherlands ndf Amsterdam

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.69.0 2024