You are here

function entity_embed_test_entity_embed_alter in Entity Embed 8

Same name and namespace in other branches
  1. 7.3 tests/entity_embed_test.module \entity_embed_test_entity_embed_alter()
  2. 7 tests/entity_embed_test.module \entity_embed_test_entity_embed_alter()
  3. 7.2 tests/entity_embed_test.module \entity_embed_test_entity_embed_alter()

Implements hook_entity_embed_alter().

1 string reference to 'entity_embed_test_entity_embed_alter'
EntityEmbedHooksTest::testEntityEmbedHooks in tests/src/Functional/EntityEmbedHooksTest.php
Tests the hooks provided by entity_embed module.

File

tests/modules/entity_embed_test/entity_embed_test.module, line 68
Helper module for the Entity Embed tests.

Code

function entity_embed_test_entity_embed_alter(array &$build, EntityInterface $entity, array $context) {

  // Allow tests to enable or disable this hook.
  if (!\Drupal::state()
    ->get('entity_embed_test_entity_embed_alter', FALSE)) {
    return;
  }

  // Adding classes is as simple as appending to an array.
  $build['#attributes']['class'][] = 'test-class-added-in-alter-hook';

  // Set title of the 'node' entity.
  $entity
    ->setTitle("Title set by hook_entity_embed_alter");
}