X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;ds=inline;f=web%2Fmodules%2Fcontrib%2Fentity_embed%2Fentity_embed.module;fp=web%2Fmodules%2Fcontrib%2Fentity_embed%2Fentity_embed.module;h=fbdd99434e5d9694a35bf3d6930f13becf2ba9ca;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/entity_embed/entity_embed.module b/web/modules/contrib/entity_embed/entity_embed.module new file mode 100644 index 000000000..fbdd99434 --- /dev/null +++ b/web/modules/contrib/entity_embed/entity_embed.module @@ -0,0 +1,66 @@ + [ + 'render element' => 'element', + ], + ]; +} + +/** + * Prepares variables for entity embed container templates. + * + * Default template: entity-embed-container.html.twig. + * + * @param array $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #children. + */ +function template_preprocess_entity_embed_container(&$variables) { + $variables['element'] += ['#attributes' => []]; + $variables['attributes'] = $variables['element']['#attributes']; + $variables['children'] = $variables['element']['#children']; +} + +/** + * Implements hook_entity_embed_display_plugins_alter() on behalf of file.module. + */ +function file_entity_embed_display_plugins_alter(array &$plugins) { + // The RSS enclosure field formatter is not usable for Entity Embed. + unset($plugins['file:file_rss_enclosure']); +} + +/** + * Implements hook_entity_embed_display_plugins_alter() on behalf of taxonomy.module. + */ +function taxonomy_entity_embed_display_plugins_alter(array &$plugins) { + // The RSS category field formatter is not usable for Entity Embed. + unset($plugins['entity_reference:entity_reference_rss_category']); +} + +/** + * Implements hook_entity_embed_display_plugins_for_context_alter(). + * + * The 'Rendered entity' formatter can not be used for files unless the + * file_entity module is available. + * + * @see https://www.drupal.org/node/2468387 + * + * @todo Remove when https://www.drupal.org/node/2567919 is fixed in core. + */ +function entity_embed_entity_embed_display_plugins_for_context_alter(array &$definitions, array $context) { + if ($context['entity_type'] === 'file' && !\Drupal::moduleHandler()->moduleExists('file_entity')) { + unset($definitions['entity_reference:entity_reference_entity_view']); + } +}