You are here

protected function EntityToTableRenderer::getDisplayRenderer in Reference Table Formatter 8

Same name and namespace in other branches
  1. 2.0.x src/EntityToTableRenderer.php \Drupal\reference_table_formatter\EntityToTableRenderer::getDisplayRenderer()

Get the display renderer.

Parameters

string $type: The entity type.

string $bundle: The entity bundle.

string $view_mode: The view mode.

Return value

\Drupal\Core\Entity\EntityInterface The display renderer.

1 call to EntityToTableRenderer::getDisplayRenderer()
EntityToTableRenderer::getPreparedRenderedEntities in src/EntityToTableRenderer.php
Prepare all of the given entities for rendering with applicable fields.

File

src/EntityToTableRenderer.php, line 140

Class

EntityToTableRenderer
A service for turning entities into tables.

Namespace

Drupal\reference_table_formatter

Code

protected function getDisplayRenderer($type, $bundle, $view_mode) {

  // For entities with no bundles, the bundle type always defaults to the
  // entity type. This is a hardcoded constraint made in core,
  // see ContentEntityBase::__construct.
  $bundle = $bundle ?: $type;
  $storage = $this->entityManager
    ->getStorage('entity_view_display');

  // When a display renderer doesn't exist, fall back to the default.
  $renderer = $storage
    ->load(implode('.', [
    $type,
    $bundle,
    $view_mode,
  ]));
  if (!$renderer) {
    $renderer = $this->displayRepository
      ->getViewDisplay($type, $bundle, 'default');
  }
  return $renderer;
}