function theme_settings_convert_to_config

Same name in other branches
  1. 8.9.x core/includes/theme.inc \theme_settings_convert_to_config()
  2. 10 core/includes/theme.inc \theme_settings_convert_to_config()
  3. 11.x core/includes/theme.inc \theme_settings_convert_to_config()

Converts theme settings to configuration.

Parameters

array $theme_settings: An array of theme settings from system setting form or a Drupal 7 variable.

\Drupal\Core\Config\Config $config: The configuration object to update.

Return value

\Drupal\Core\Config\Config The Config object with updated data.

See also

system_theme_settings_submit()

1 call to theme_settings_convert_to_config()
ThemeSettings::import in core/modules/system/src/Plugin/migrate/destination/d7/ThemeSettings.php
Import the row.

File

core/includes/theme.inc, line 482

Code

function theme_settings_convert_to_config(array $theme_settings, Config $config) {
    foreach ($theme_settings as $key => $value) {
        if ($key == 'default_logo') {
            $config->set('logo.use_default', $value);
        }
        elseif ($key == 'logo_path') {
            $config->set('logo.path', $value);
        }
        elseif ($key == 'default_favicon') {
            $config->set('favicon.use_default', $value);
        }
        elseif ($key == 'favicon_path') {
            $config->set('favicon.path', $value);
        }
        elseif ($key == 'favicon_mimetype') {
            $config->set('favicon.mimetype', $value);
        }
        elseif (substr($key, 0, 7) == 'toggle_') {
            $config->set('features.' . mb_substr($key, 7), $value);
        }
        elseif (!in_array($key, [
            'theme',
            'logo_upload',
        ])) {
            $config->set($key, $value);
        }
    }
    return $config;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.