You are here

public function ContentEntityRenderer::getHtmlMultiple in Entity Print 8

Generate the HTML for our entity.

Parameters

array $entities: An array of entities to generate the HTML for.

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::getHtmlMultiple

File

src/Renderer/ContentEntityRenderer.php, line 50

Class

ContentEntityRenderer

Namespace

Drupal\entity_print\Renderer

Code

public function getHtmlMultiple($entities, $use_default_css, $optimize_css) {
  $first_entity = reset($entities);
  $render_controller = $this->entityTypeManager
    ->getViewBuilder($first_entity
    ->getEntityTypeId());

  // @TODO, maybe we should implement a different theme function?
  $render = [
    '#theme' => 'entity_print__' . $first_entity
      ->getEntityTypeId(),
    '#entity' => $entities,
    '#entity_array' => $render_controller
      ->viewMultiple($entities, $this
      ->getViewMode($first_entity)),
    '#attached' => [],
  ];
  return $this
    ->generateHtml($render, $entities, $use_default_css, $optimize_css);
}