color_block_view_pre_render

color_block_view_pre_render(array $build)

#pre_render callback: Sets color preset logo.

File

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

Code

function color_block_view_pre_render(array $build) {
  $theme_key = \Drupal::theme()->getActiveTheme()->getName();
  $config = \Drupal::config('color.theme.' . $theme_key);
  CacheableMetadata::createFromRenderArray($build)
    ->addCacheableDependency($config)
    ->applyTo($build);

  // Override logo.
  $logo = $config->get('logo');
  if ($logo && $build['content']['site_logo'] && preg_match('!' . $theme_key . '/logo.svg$!', $build['content']['site_logo']['#uri'])) {
    $build['content']['site_logo']['#uri'] = file_url_transform_relative(file_create_url($logo));
  }

  return $build;
}
doc_Drupal
2016-10-29 08:50:07
Comments
Leave a Comment

Please login to continue.