You are here

function hook_gutenberg_block_view_alter in Gutenberg 8.2

Alter the result of \Drupal\gutenberg\BlockProcessor\DynamicRenderProcessor.

This hook is called after the block has been assembled in a structured array and may be used for doing processing which requires that the complete block content structure has been built.

If the module wishes to act on the rendered HTML of the block rather than the structured content array, it may use this hook to add a #post_render callback. Alternatively, it could also implement hook_preprocess_HOOK() for gutenberg-block.html.twig. See drupal_render() documentation or the Default theme implementations topic for details.

Parameters

array &$build: A renderable array of the block.

string $block_content: The block's inner HTML.

See also

hook_gutenberg_block_view_BASE_BLOCK_ID_alter()

\Drupal\gutenberg\BlockProcessor\DynamicRenderProcessor::processBlock()

File

./gutenberg.api.php, line 111
Documentation for Gutenberg module APIs.

Code

function hook_gutenberg_block_view_alter(array &$build, &$block_content) {

  // Add generic pre_render hook for all dynamic blocks.
  $build['#pre_render'][] = 'hook_gutenberg_pre_render';
}