Same name and namespace in other branches
  1. 8.9.x core/modules/block/tests/modules/block_test/block_test.module \block_test_block_view_test_cache_alter()
  2. 9 core/modules/block/tests/modules/block_test/block_test.module \block_test_block_view_test_cache_alter()

Implements hook_block_view_BASE_BLOCK_ID_alter().

File

core/modules/block/tests/modules/block_test/block_test.module, line 23
Provide test blocks.

Code

function block_test_block_view_test_cache_alter(array &$build, BlockPluginInterface $block) {
  if (\Drupal::state()
    ->get('block_test_view_alter_suffix') !== NULL) {
    $build['#attributes']['foo'] = 'bar';
  }
  if (\Drupal::state()
    ->get('block_test_view_alter_append_pre_render_prefix') !== NULL) {
    $build['#pre_render'][] = '\\Drupal\\block_test\\BlockRenderAlterContent::preRender';
  }
}