class ColorSystemBrandingBlockAlter in Drupal 9
Same name and namespace in other branches
- 8 core/modules/color/src/ColorSystemBrandingBlockAlter.php \Drupal\color\ColorSystemBrandingBlockAlter
Provides a trusted callback to alter the system branding block.
Hierarchy
- class \Drupal\color\ColorSystemBrandingBlockAlter implements RenderCallbackInterface
Expanded class hierarchy of ColorSystemBrandingBlockAlter
See also
color_block_view_system_branding_block_alter()
1 file declares its use of ColorSystemBrandingBlockAlter
- color.module in core/
modules/ color/ color.module - Allows users to change the color scheme of themes.
File
- core/
modules/ color/ src/ ColorSystemBrandingBlockAlter.php, line 13
Namespace
Drupal\colorView source
class ColorSystemBrandingBlockAlter implements RenderCallbackInterface {
/**
* #pre_render callback: Sets color preset logo.
*/
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'] = \Drupal::service('file_url_generator')
->generateString($logo);
}
return $build;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ColorSystemBrandingBlockAlter:: |
public static | function | #pre_render callback: Sets color preset logo. |