public function EntityEmbedTwigExtension::getRenderArray in Entity Embed 8
Return the render array for an entity.
Parameters
string $entity_type: The machine name of an entity_type like 'node'.
string $entity_id: The entity ID.
string $display_plugin: (optional) The Entity Embed Display plugin to be used to render the entity.
array $display_settings: (optional) A list of settings for the Entity Embed Display plugin.
Return value
array A render array from entity_view().
File
- src/
Twig/ EntityEmbedTwigExtension.php, line 83
Class
- EntityEmbedTwigExtension
- Provide entity embedding function within Twig templates.
Namespace
Drupal\entity_embed\TwigCode
public function getRenderArray($entity_type, $entity_id, $display_plugin = 'default', array $display_settings = []) {
$entity = $this->entityTypeManager
->getStorage($entity_type)
->load($entity_id);
$context = [
'data-entity-type' => $entity_type,
'data-entity-uuid' => $entity
->uuid(),
'data-entity-embed-display' => $display_plugin,
'data-entity-embed-display-settings' => $display_settings,
];
return $this->builder
->buildEntityEmbed($entity, $context);
}