function entity_view_multiple
Returns the render array for the provided entities.
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
in drupal:8.0.0 and is removed from drupal:9.0.0. Use the entity view builder's viewMultiple() method for creating a render array for the provided entities:
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId());
return $view_builder->viewMultiple($entities, $view_mode, $langcode);
See also
https://www.drupal.org/node/3033656
\Drupal\Core\Entity\EntityTypeManagerInterface::getViewBuilder()
\Drupal\Core\Entity\EntityViewBuilderInterface::viewMultiple()
1 call to entity_view_multiple()
- EntityLegacyTest::testEntityView in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityLegacyTest.php - @expectedDeprecation entity_view() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, $view_mode, $langcode) instead. Seeā¦
File
-
core/
includes/ entity.inc, line 381
Code
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
@trigger_error('entity_view_multiple() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \\Drupal::entityTypeManager()->getViewBuilder($entity->getEntityTypeId())->viewMultiple($entities, $view_mode, $langcode) instead. See https://www.drupal.org/node/3033656', E_USER_DEPRECATED);
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId());
if ($reset) {
$render_controller->resetCache($entities);
}
return $render_controller->viewMultiple($entities, $view_mode, $langcode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.