1 config_test_hooks.module config_test_hooks_config_create(Config $staging_config)

Implements hook_config_create().

File

core/modules/config/tests/config_test_hooks/config_test_hooks.module, line 43
Tests the hooks provided by Configuration management module.

Code

function config_test_hooks_config_create(Config $staging_config) {
  if ($staging_config->getName() === 'config_test.new_config') {
    // Set a value before the config is saved.
    $staging_config->set('favorite_color', 'red');
  }
  if ($staging_config->getName() === 'config_test.simple') {
    // Set a value on the config file in another module when it is enabled.
    $config = config('config_test_hooks.data');
    $config->set('favorite_cheese', 'cheddar');
    $config->save();
  }
}