media_test_embed.module

Same filename in other branches
  1. 9 core/modules/media/tests/modules/media_test_embed/media_test_embed.module
  2. 11.x core/modules/media/tests/modules/media_test_embed/media_test_embed.module

Helper module for the Media Embed text editor plugin tests.

File

core/modules/media/tests/modules/media_test_embed/media_test_embed.module

View source
<?php


/**
 * @file
 * Helper module for the Media Embed text editor plugin tests.
 */
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;

/**
 * Implements hook_entity_view_alter().
 */
function media_test_embed_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
    $build['#attributes']['data-media-embed-test-active-theme'] = \Drupal::theme()->getActiveTheme()
        ->getName();
    $build['#attributes']['data-media-embed-test-view-mode'] = $display->getMode();
}

/**
 * Implements hook_preprocess_HOOK().
 */
function media_test_embed_preprocess_media_embed_error(&$variables) {
    $variables['attributes']['class'][] = 'this-error-message-is-themeable';
}

/**
 * Implements hook_entity_access().
 */
function media_test_embed_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
    return AccessResult::neutral()->addCacheTags([
        '_media_test_embed_filter_access:' . $entity->getEntityTypeId() . ':' . $entity->id(),
    ]);
}

Functions

Title Deprecated Summary
media_test_embed_entity_access Implements hook_entity_access().
media_test_embed_entity_view_alter Implements hook_entity_view_alter().
media_test_embed_preprocess_media_embed_error Implements hook_preprocess_HOOK().

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