function block_test_block_view_test_cache_alter

Same name and namespace in other branches
  1. 9 core/modules/block/tests/modules/block_test/block_test.module \block_test_block_view_test_cache_alter()
  2. 8.9.x core/modules/block/tests/modules/block_test/block_test.module \block_test_block_view_test_cache_alter()
  3. 10 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

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';
    }
}

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