You are here

public function ContentEntityRenderer::getHtml in Entity Print 8

Generate the HTML for our entity.

Parameters

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

bool $use_default_css: TRUE if we should inject our default CSS otherwise FALSE.

bool $optimize_css: TRUE if we should compress the CSS otherwise FALSE.

Return value

string The generated HTML.

Throws

\Exception

Overrides RendererInterface::getHtml

File

src/Renderer/ContentEntityRenderer.php, line 35

Class

ContentEntityRenderer

Namespace

Drupal\entity_print\Renderer

Code

public function getHtml(EntityInterface $entity, $use_default_css, $optimize_css) {
  $render_controller = $this->entityTypeManager
    ->getViewBuilder($entity
    ->getEntityTypeId());
  $render = [
    '#theme' => 'entity_print__' . $entity
      ->getEntityTypeId() . '__' . $entity
      ->bundle() . '__' . $this
      ->getViewMode($entity) . '__' . $entity
      ->id(),
    '#entity' => $entity,
    '#entity_array' => $render_controller
      ->view($entity, $this
      ->getViewMode($entity)),
    '#attached' => [],
  ];
  return $this
    ->generateHtml($render, [
    $entity,
  ], $use_default_css, $optimize_css);
}