O'Reilly logo

Drupal 8 Module Development by Daniel Sipos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Module overrides

Although you can simply use the global $config array, that is not really the place where modules should be tinkering. First of all, because it's a global variable and it's never a good idea to change global variables, it should be mostly left to the settings.php. Second of all, because there is no way of controlling priority if multiple places try to change it in the same way. Instead, we have the module override system that we can use.

Via the module overrides, we can create a service with the config.factory.override tag (remember what tagged services are?) and in this service handle our overrides. Let's use this system to override the maintenance mode message. Inside our Hello World module, we can have the following service ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required