function template_preprocess_block

Same name in other branches
  1. 7.x modules/block/block.module \template_preprocess_block()
  2. 9 core/modules/block/block.module \template_preprocess_block()
  3. 8.9.x core/modules/block/block.module \template_preprocess_block()
  4. 10 core/modules/block/block.module \template_preprocess_block()

Prepares variables for block templates.

Default template: block.html.twig.

Prepares the values passed to the theme_block function to be passed into a pluggable template engine. Uses block properties to generate a series of template file suggestions. If none are found, the default block.html.twig is used.

Most themes use their own copy of block.html.twig. The default is located inside "core/modules/block/templates/block.html.twig". Look in there for the full list of available variables.

Parameters

array $variables: An associative array containing:

  • elements: An associative array containing the properties of the element. Properties used: #block, #configuration, #children, #plugin_id.

Deprecated

in drupal:11.2.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme().

See also

https://www.drupal.org/node/3504125

File

core/modules/block/block.module, line 128

Code

function template_preprocess_block(&$variables) : void {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.2.0 and is removed from drupal:12.0.0. Initial template_preprocess functions are registered directly in hook_theme(). See https://www.drupal.org/node/3504125', E_USER_DEPRECATED);
    \Drupal::service(BlockHooks::class)->preprocessBlock($variables);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.