Completed
Push — 8.x-1.x ( 6cff3f...08e509 )
by Janez
02:05
created

entity_embed.module::file_entity_embed_display_plugins_alter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * @file
5
 * Framework for allowing entities to be embedded using CKEditor plugin and text
6
 * format.
7
 */
8
9
/**
10
 * Implements hook_entity_embed_display_plugins_alter() on behalf of file.module.
11
 */
12
function file_entity_embed_display_plugins_alter(array &$plugins) {
13
  // The RSS enclosure field formatter is not usable for Entity Embed.
14
  unset($plugins['file:file_rss_enclosure']);
15
}
16
17
/**
18
 * Implements hook_entity_embed_display_plugins_alter() on behalf of taxonomy.module.
19
 */
20
function taxonomy_entity_embed_display_plugins_alter(array &$plugins) {
21
  // The RSS category field formatter is not usable for Entity Embed.
22
  unset($plugins['entity_reference:entity_reference_rss_category']);
23
}
24
25
/**
26
 * Implements hook_entity_embed_display_plugins_for_context_alter().
27
 *
28
 * The 'Rendered entity' formatter can not be used for files unless the
29
 * file_entity module is available.
30
 * @see https://www.drupal.org/node/2468387
31
 * @todo Remove when https://www.drupal.org/node/2567919 is fixed in core.
32
 */
33
function entity_embed_entity_embed_display_plugins_for_context_alter(array &$definitions, array $context) {
34
  if ($context['entity_type'] === 'file' && !\Drupal::moduleHandler()->moduleExists('file_entity')) {
35
    unset($definitions['entity_reference:entity_reference_entity_view']);
36
  }
37
}
38