function color_get_palette

Same name in other branches
  1. 7.x modules/color/color.module \color_get_palette()
  2. 8.9.x core/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

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;
}

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