bundle(), ['audio', 'video'])) { $definitions = array_intersect_key($definitions, array_flip(['file:jwplayer_formatter'])); } // For images, use the image formatter. if ($entity instanceof \Drupal\file\FileInterface && in_array($entity->bundle(), ['image'])) { $definitions = array_intersect_key($definitions, array_flip(['image:image'])); } // For nodes, use the default option. if ($entity instanceof \Drupal\node\NodeInterface) { $definitions = array_intersect_key($definitions, array_flip(['entity_reference:entity_reference_entity_view'])); } } /** * Alter the context of an embedded entity before it is rendered. * * @param array &$context * The context array. * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object. */ function hook_entity_embed_context_alter(array &$context, \Drupal\Core\Entity\EntityInterface $entity) { if (isset($context['overrides']) && is_array($context['overrides'])) { foreach ($context['overrides'] as $key => $value) { $entity->key = $value; } } } /** * Alter the context of an particular embedded entity type before it is rendered. * * @param array &$context * The context array. * @param \Drupal\Core\Entity\EntityInterface $entity * The entity object. */ function hook_ENTITY_TYPE_embed_context_alter(array &$context, \Drupal\Core\Entity\EntityInterface $entity) { if (isset($context['overrides']) && is_array($context['overrides'])) { foreach ($context['overrides'] as $key => $value) { $entity->key = $value; } } } /** * Alter the results of an embedded entity build array. * * This hook is called after the content has been assembled in a structured * array and may be used for doing processing which requires that the complete * block content structure has been built. * * @param array &$build * A renderable array representing the embedded entity content. * @param \Drupal\Core\Entity\EntityInterface $entity * The embedded entity object. * @param array $context * The context array. */ function hook_entity_embed_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, array &$context) { // Remove the contextual links. if (isset($build['#contextual_links'])) { unset($build['#contextual_links']); } } /** * Alter the results of the particular embedded entity type build array. * * @param array &$build * A renderable array representing the embedded entity content. * @param \Drupal\Core\Entity\EntityInterface $entity * The embedded entity object. * @param array $context * The context array. */ function hook_ENTITY_TYPE_embed_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, array &$context) { // Remove the contextual links. if (isset($build['#contextual_links'])) { unset($build['#contextual_links']); } } /** * @} End of "addtogroup hooks". */