5 * Framework for allowing entities to be embedded using CKEditor plugin and text
10 * Implements hook_theme().
12 function entity_embed_theme() {
14 'entity_embed_container' => [
15 'render element' => 'element',
21 * Prepares variables for entity embed container templates.
23 * Default template: entity-embed-container.html.twig.
25 * @param array $variables
26 * An associative array containing:
27 * - element: An associative array containing the properties of the element.
28 * Properties used: #attributes, #children.
30 function template_preprocess_entity_embed_container(&$variables) {
31 $variables['element'] += ['#attributes' => []];
32 $variables['attributes'] = $variables['element']['#attributes'];
33 $variables['children'] = $variables['element']['#children'];
37 * Implements hook_entity_embed_display_plugins_alter() on behalf of file.module.
39 function file_entity_embed_display_plugins_alter(array &$plugins) {
40 // The RSS enclosure field formatter is not usable for Entity Embed.
41 unset($plugins['file:file_rss_enclosure']);
45 * Implements hook_entity_embed_display_plugins_alter() on behalf of taxonomy.module.
47 function taxonomy_entity_embed_display_plugins_alter(array &$plugins) {
48 // The RSS category field formatter is not usable for Entity Embed.
49 unset($plugins['entity_reference:entity_reference_rss_category']);
53 * Implements hook_entity_embed_display_plugins_for_context_alter().
55 * The 'Rendered entity' formatter can not be used for files unless the
56 * file_entity module is available.
58 * @see https://www.drupal.org/node/2468387
60 * @todo Remove when https://www.drupal.org/node/2567919 is fixed in core.
62 function entity_embed_entity_embed_display_plugins_for_context_alter(array &$definitions, array $context) {
63 if ($context['entity_type'] === 'file' && !\Drupal::moduleHandler()->moduleExists('file_entity')) {
64 unset($definitions['entity_reference:entity_reference_entity_view']);