You are here

protected function ContentEntityRenderer::getViewMode in Entity Print 8

Same name and namespace in other branches
  1. 8.2 src/Renderer/ContentEntityRenderer.php \Drupal\entity_print\Renderer\ContentEntityRenderer::getViewMode()

Gets the view mode to use for this entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The content entity we're viewing.

Return value

string The view mode machine name.

2 calls to ContentEntityRenderer::getViewMode()
ContentEntityRenderer::getHtml in src/Renderer/ContentEntityRenderer.php
Generate the HTML for our entity.
ContentEntityRenderer::getHtmlMultiple in src/Renderer/ContentEntityRenderer.php
Generate the HTML for our entity.

File

src/Renderer/ContentEntityRenderer.php, line 113

Class

ContentEntityRenderer

Namespace

Drupal\entity_print\Renderer

Code

protected function getViewMode(EntityInterface $entity) {

  // We check to see if the PDF view display have been configured, if not
  // then we simply fall back to the full display.
  $view_mode = 'pdf';
  if (!$this->entityTypeManager
    ->getStorage('entity_view_display')
    ->load($entity
    ->getEntityTypeId() . '.' . $entity
    ->bundle() . '.' . $view_mode)) {
    $view_mode = 'full';
  }
  return $view_mode;
}