You are here

media_test_filter.module in Drupal 8

Helper module for the Media Embed filter tests.

File

core/modules/media/tests/modules/media_test_filter/media_test_filter.module
View source
<?php

/**
 * @file
 * Helper module for the Media Embed filter 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_access().
 */
function media_test_filter_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
  return AccessResult::neutral()
    ->addCacheTags([
    '_media_test_filter_access:' . $entity
      ->getEntityTypeId() . ':' . $entity
      ->id(),
  ]);
}

/**
 * Implements hook_entity_view_alter().
 */
function media_test_filter_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
  $build['#attributes']['data-media-embed-test-view-mode'] = $display
    ->getMode();
}

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