Providing configuration settings for your module
Modules can leverage configuration settings to allow end users to modify how they operate. These pieces of configuration are YAML files. Modules can also provide default configuration for other modules when they are installed. Once the module has been installed, the default configuration it provides is imported into Drupal. Modules may also modify existing configurations programmatically through an installation hook or update hooks.
In this recipe, we will provide a configuration that creates a new contact form and then manipulates it through an update hook.
Getting ready
This recipe requires a custom module, like the one created in the first recipe. We will refer to the module as mymodule
throughout this recipe. Use your module’s appropriate name where necessary.
How to do it…
- Create a
config
folder in your module’s directory. Then, in that directory, create aninstall
directory. Drupal looks...