Change record status: 
Introduced in branch: 
8.x
Introduced in version: 
Description: 

In earlier versions of Drupal 8, the entity_get_render_display() & entity_get_render_form_display() functions were used to retrive the EntityViewDisplay or EntityFormDisplay object used to render an entity in a given view mode / form mode.

This functions enclosed the logic determining which Display object to use at render time - either:
- the Display associated to the view mode / form mode if it exists and its 'status' is set to 1
- the Display associated to the 'default' mode otherwise.

Those functions have been replaced by statoc methods on the EntityViewDisplay and EntityFormDisplay classes:

$view_display = EntityViewDisplay::collectRenderDisplay(ContentEntityInterface $entity, $view_mode);
$form_display = EntityFormDisplay::collectRenderDisplay(ContentEntityInterface $entity, $view_mode);

In the case of EntityViewDisplay, a "multiple" variant is available, and should be preferred when rendering multiple entities:

$view_displays = EntityViewDisplay::collectRenderDisplay(array $entities, $view_mode); 

The result is an array of EntityViewDisplay objects, keyed by entity bundle name (covers the entity bundles present in the the $entities array).

Impacts: 
Module developers