improved_theme_settings.install in Open Social 10.3.x
Same filename and directory in other branches
- 8.9 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.2 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.3 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.4 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.5 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.6 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.7 modules/custom/improved_theme_settings/improved_theme_settings.install
- 8.8 modules/custom/improved_theme_settings/improved_theme_settings.install
- 10.0.x modules/custom/improved_theme_settings/improved_theme_settings.install
- 10.1.x modules/custom/improved_theme_settings/improved_theme_settings.install
- 10.2.x modules/custom/improved_theme_settings/improved_theme_settings.install
Improved theme settings module install file.
File
modules/custom/improved_theme_settings/improved_theme_settings.installView source
<?php
/**
* @file
* Improved theme settings module install file.
*/
/**
* Implements hook_install().
*
* Perform actions related to the installation of improved_theme_settings.
*/
function improved_theme_settings_install() {
// Set weight.
module_set_weight('improved_theme_settings', 50);
}
/**
* Migrate old theme settings to the new settings.
*/
function improved_theme_settings_update_8001() {
// Get the current default theme.
$theme = \Drupal::configFactory()
->get('system.theme')
->get('default');
// Get the color values.
$config = \Drupal::configFactory()
->getEditable('color.theme.' . $theme);
$colors = $config
->getRawData();
// Create an array for the new color values.
$new_colors = [
'brand-primary' => '#29abe2',
'brand-secondary' => '#1f80aa',
'brand-accent' => '#ffc142',
'brand-link' => '#33b5e5',
'navbar-bg' => '#333333',
'navbar-text' => '#ffffff',
'navbar-active-bg' => '#1f1f1f',
'navbar-active-text' => '#f3f3f3',
'navbar-sec-bg' => '#1f7ea7',
'navbar-sec-text' => '#f9f9f9',
];
// Fetch values from the old theme and overrode em.
if (isset($colors['palette']['brand-bg-primary'])) {
$new_colors['brand-primary'] = $colors['palette']['brand-bg-primary'];
}
if (isset($colors['palette']['brand-bg-secondary'])) {
$new_colors['brand-secondary'] = $colors['palette']['brand-bg-secondary'];
}
if (isset($colors['palette']['brand-bg-accent'])) {
$new_colors['brand-accent'] = $colors['palette']['brand-bg-accent'];
}
if (isset($colors['palette']['brand-text-primary'])) {
$new_colors['brand-link'] = $colors['palette']['brand-text-primary'];
}
// overwrite.
$colors['palette'] = $new_colors;
// Save the new config.
$config
->setData($colors)
->save();
}Functions
|
Name |
Description |
|---|---|
| improved_theme_settings_install | Implements hook_install(). |
| improved_theme_settings_update_8001 | Migrate old theme settings to the new settings. |