A simple configuration API
As you learned earlier in this book, there are several types of configuration objects in Drupal 8: simple configuration and the more complex configuration entities.
Working with configuration data
If you've worked with Drupal 7 before and have written some custom code, you will surely remember the variable subsystem. Drupal 7 itself and many modules store their settings in the {variable}
database table. Every configuration saved to this table needs to be serialized before saving and converted back to its original state while reading from the table. To read and write configuration, Drupal 7 has the widely used functions variable_get($name)
and variable_set($name, $value)
.
Here are some small examples of how Drupal 7 reads and saves simple configuration settings, taken from system.admin.inc
:
<?php // The status message depends on whether an admin theme is currently in use: // a value of 0 means the admin theme is set to be the default theme. $admin_theme =...