class ColorSystemBrandingBlockAlter
Same name and namespace in other branches
- 8.9.x 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 \Drupal\Core\Render\Element\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
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ColorSystemBrandingBlockAlter::preRender | public static | function | #pre_render callback: Sets color preset logo. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.