You are here

ch_block_content_test.module in Acquia Content Hub 8

A dummy module for testing custom block related hooks.

This is a dummy module that implements custom block related hooks to test API interaction with the block_content module.

File

tests/modules/ch_block_content_test/ch_block_content_test.module
View source
<?php

/**
 * @file
 * A dummy module for testing custom block related hooks.
 *
 * This is a dummy module that implements custom block related hooks to test API
 * interaction with the block_content module.
 */
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;

/**
 * Implements hook_block_content_view().
 */
function ch_block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) {

  // Add extra content.
  $build['hook_block_content_view']['#markup'] = '[hook_block_content_view]';
}

/**
 * Implements hook_ENTITY_TYPE_view_alter().
 */
function ch_block_content_test_block_content_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $build['#attributes']['class'][] = 'my-very-special-class';
  $build['hook_block_content_view_alter']['#markup'] = '[hook_block_content_view_alter]';
}

Functions