You are here

public function ContentEntityDisplayController::viewEntityViewMode in Acquia Content Hub 8

View entity view mode, given entity and view mode name.

Parameters

string $entity_type: The Drupal Entity Type.

int $entity_id: The Drupal Entity Id.

string $view_mode_name: The view mode's name.

Return value

array A render array as expected by drupal_render().

1 string reference to 'ContentEntityDisplayController::viewEntityViewMode'
acquia_contenthub.routing.yml in ./acquia_contenthub.routing.yml
acquia_contenthub.routing.yml

File

src/Controller/ContentEntityDisplayController.php, line 75

Class

ContentEntityDisplayController
Class ContentEntityDisplayController.

Namespace

Drupal\acquia_contenthub\Controller

Code

public function viewEntityViewMode($entity_type, $entity_id, $view_mode_name = 'teaser') {

  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $this->entityTypeManager
    ->getStorage($entity_type)
    ->load($entity_id);
  $page = $this->contentEntityViewModesExtractor
    ->getViewModeMinimalHtml($entity, $view_mode_name);
  return $page;
}