function ColorSystemBrandingBlockAlter::preRender
Same name in other branches
- 9 core/modules/color/src/ColorSystemBrandingBlockAlter.php \Drupal\color\ColorSystemBrandingBlockAlter::preRender()
#pre_render callback: Sets color preset logo.
1 call to ColorSystemBrandingBlockAlter::preRender()
- color_block_view_pre_render in core/
modules/ color/ color.module - #pre_render callback: Sets color preset logo.
File
-
core/
modules/ color/ src/ ColorSystemBrandingBlockAlter.php, line 18
Class
- ColorSystemBrandingBlockAlter
- Provides a trusted callback to alter the system branding block.
Namespace
Drupal\colorCode
public static function preRender($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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.