function template_preprocess_color_scheme_form

template_preprocess_color_scheme_form(&$variables)

Prepares variables for color scheme form templates.

Default template: color-scheme-form.html.twig.

Parameters

array $variables: An associative array containing:

  • form: A render element representing the form.

File

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

Code

function template_preprocess_color_scheme_form(&$variables) {
  $form = &$variables['form'];

  $theme = $form['theme']['#value'];
  $info = $form['info']['#value'];

  if (isset($info['preview_library'])) {
    $form['scheme']['#attached']['library'][] = $info['preview_library'];
  }

  // Attempt to load preview HTML if the theme provides it.
  $preview_html_path = \Drupal::root() . '/' . (isset($info['preview_html']) ? drupal_get_path('theme', $theme) . '/' . $info['preview_html'] : drupal_get_path('module', 'color') . '/preview.html');
  $variables['html_preview']['#markup'] = file_get_contents($preview_html_path);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!color!color.module/function/template_preprocess_color_scheme_form/8.1.x