media_test_embed.module in Drupal 10
Same filename and directory in other branches
Helper module for the Media Embed text editor plugin tests.
File
core/modules/media/tests/modules/media_test_embed/media_test_embed.moduleView 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
Name | Description |
---|---|
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(). |