You are here

function color_get_palette in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/color/color.module \color_get_palette()
  2. 5 modules/color/color.module \color_get_palette()
  3. 6 modules/color/color.module \color_get_palette()
  4. 7 modules/color/color.module \color_get_palette()

Retrieves the color palette for a particular theme.

3 calls to color_get_palette()
color_scheme_form in core/modules/color/color.module
Form constructor for the color configuration form for a particular theme.
color_scheme_form_submit in core/modules/color/color.module
Form submission handler for color_scheme_form().
_color_rewrite_stylesheet in core/modules/color/color.module
Rewrites the stylesheet to match the colors in the palette.

File

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

Code

function color_get_palette($theme, $default = FALSE) {

  // Fetch and expand default palette.
  $info = color_get_info($theme);
  $palette = $info['schemes']['default']['colors'];
  if ($default) {
    return $palette;
  }

  // Load variable.
  // @todo Default color config should be moved to yaml in the theme.
  // Getting a mutable override-free object because this function is only used
  // in forms. Color configuration is used to write CSS to the file system
  // making configuration overrides pointless.
  return \Drupal::configFactory()
    ->getEditable('color.theme.' . $theme)
    ->get('palette') ?: $palette;
}