1 color.module _color_config_save(Config $staging_config)

Shared callback used by color_config_create() and hook_config_update().

Parameters

Config $staging_config: The configuration about to be imported into the site.

File

core/modules/color/color.module, line 344
Allows users to change the color scheme of themes.

Code

function _color_config_save(Config $staging_config) {
  // Match "[theme_name].settings" config names.
  $config_name = $staging_config->getName();
  list($theme_name, $settings) = explode('.', $config_name);
  if ($settings === 'settings') {
    $themes = list_themes();
    if (array_key_exists($theme_name, $themes)) {
      $new_color_config = $staging_config->get('color');
      $color_info = color_get_info($theme_name);
      if ($color_info) {
        $palette = isset($new_color_config['palette']) ? $new_color_config['palette'] : NULL;
        $updated_config = color_save_configuration($theme_name, $color_info, $palette);
        // Update the staged config with the new CSS file location. Saving is
        // done right after this hook by config_sync_file().
        $staging_config->set('color', $updated_config);
      }
    }
  }
}