Global overrides

In Drupal 8, we still have the global override possibility via a global variable, this time called $config. This variable is available in the settings.php file for site-wide overrides, but you can also use it inside your module (if you really have to!) in order to override a specific piece of configuration:

global $config;$config['system.maintenance']['message'] = 'Our own message for the site maintenance mode';

In this example we changed, on the fly, the message used for the site maintenance mode. Why one would want to do that is beside the point, but you may have some other configuration which would benefit from being overridable like this. In any case, you notice the array notation we use. The first key is the name of ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.