function entity_view_multiple in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/entity.inc \entity_view_multiple()
Returns the render array for the provided entities.
$view_builder = \Drupal::entityManager()
  ->getViewBuilder($entity
  ->getEntityTypeId());
return $view_builder
  ->viewMultiple($entities, $view_mode, $langcode);Parameters
\Drupal\Core\Entity\EntityInterface[] $entities: The entities to be rendered, must be of the same type.
string $view_mode: The view mode that should be used to display the entity.
string $langcode: (optional) For which language the entity should be rendered, defaults to the current content language.
bool $reset: (optional) Whether to reset the render cache for the requested entities. Defaults to FALSE.
Return value
array A render array for the entities, indexed by the same keys as the entities array passed in $entities.
Deprecated
as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Use the entity view builder's viewMultiple() method for creating a render array for the provided entities:
See also
\Drupal\Core\Entity\EntityManagerInterface::getViewBuilder()
\Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple()
8 calls to entity_view_multiple()
- comment_view_multiple in core/modules/ comment/ comment.module 
- Constructs render array from an array of loaded comments.
- EntityLink::preRender in core/modules/ comment/ src/ Plugin/ views/ field/ EntityLink.php 
- Runs before any fields are rendered.
- EntityReferenceFieldAttributesTest::testNodeTeaser in core/modules/ rdf/ src/ Tests/ EntityReferenceFieldAttributesTest.php 
- Tests if file fields in teasers have correct resources.
- FileFieldAttributesTest::testNodeTeaser in core/modules/ rdf/ src/ Tests/ FileFieldAttributesTest.php 
- Tests if file fields in teasers have correct resources.
- node_view_multiple in core/modules/ node/ node.module 
- Constructs a drupal_render() style array from an array of loaded nodes.
File
- core/includes/ entity.inc, line 395 
- Entity API for handling entities like nodes or users.
Code
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
  $render_controller = \Drupal::entityManager()
    ->getViewBuilder(reset($entities)
    ->getEntityTypeId());
  if ($reset) {
    $render_controller
      ->resetCache($entities);
  }
  return $render_controller
    ->viewMultiple($entities, $view_mode, $langcode);
}