Author:
Source
Drupal’s modular system allows for all kinds of additions to be added to your site through plugins, entities and configuration.
Thanks to Drupal’s modular configuration system you can also inject custom configuration into existing configuration entities. This allows you to extend the functionality of an existing entity and ensure that any customisation are saved in the system configuration. Any configuration entity can be augmented without changing the existing configuration schema of the entity, which might cause knock on effects to other modules.
If you have spent time with Drupal configuration then you might have seen the addition of a third_party_settings block to your configuration. A good example of this is with the core Shortcut module and the third party settings it adds to the installed themes when the site is installed using the standard install profile. The Claro theme, for example, will have the following configuration out of the box.
third_party_settings:
shortcut:
module_link: true
This allows the Shortcut module to detect if it should show a link on the page when this theme is present on the page. The configuration for this setting then doesn’t have to live in a separate configuration entity (which would be exported into a separate file); it can just live with the configuration for the theme and be loaded as part of the theme configuration.
In this article I will look at how to use additional settings to add custom configuration items to an existing configuration entity. I’ll also cover a couple of use cases for this technique.