You are here

function render_entity_embed_display_plugin in Entity Embed 7

Same name and namespace in other branches
  1. 7.3 includes/entity_embed.display.inc \render_entity_embed_display_plugin()
  2. 7.2 includes/entity_embed.display.inc \render_entity_embed_display_plugin()

Renders an entity using an EntityEmbedDisplay plugin.

Parameters

$entity_type: The type of entity, i.e. 'node', 'user'.

$entity: The entity to be rendered.

string $plugin_id: The EntityEmbedDisplay plugin ID.

array $plugin_configuration: (optional) Array of plugin configuration values.

array $context: (optional) Array of additional context values, usually the embed HTML tag's attributes.

Return value

array A render array for the display plugin.

1 call to render_entity_embed_display_plugin()
entity_embed_render_entity in includes/entity_embed.display.inc
Renders an embedded entity.

File

includes/entity_embed.display.inc, line 90
Display functions.

Code

function render_entity_embed_display_plugin($entity_type, $entity, $plugin_id, array $plugin_configuration = array(), array $context = array()) {

  // Check if the display plugin is accessible.
  if (!entity_access('view', $entity_type, $entity)) {
    return array();
  }

  // Build and render the entity.
  $render = entity_view($entity_type, array(
    $entity,
  ), $plugin_configuration['view_mode'], $context['data-langcode']);

  // Workaround for file_entity module that does not have the patch in
  // https://www.drupal.org/node/2365821 applied yet.
  if ($entity_type === 'file' && isset($render['files'])) {
    $render = array(
      'file' => reset($render),
    );
  }
  return $render;
}