You are here

public function EntityPrintController::viewPdfDebug in Entity Print 8

A debug callback for styling up the PDF.

Parameters

string $entity_type: The entity type.

int $entity_id: The entity id.

Return value

\Symfony\Component\HttpFoundation\Response The response object.

1 string reference to 'EntityPrintController::viewPdfDebug'
entity_print.routing.yml in ./entity_print.routing.yml
entity_print.routing.yml

File

src/Controller/EntityPrintController.php, line 105

Class

EntityPrintController

Namespace

Drupal\entity_print\Controller

Code

public function viewPdfDebug($entity_type, $entity_id) {
  $entity = $this->entityTypeManager
    ->getStorage($entity_type)
    ->load($entity_id);
  try {
    $use_default_css = $this
      ->config('entity_print.settings')
      ->get('default_css');
    return new Response($this->pdfBuilder
      ->getEntityRenderedAsHtml($entity, $use_default_css, $this
      ->config('system.performance')
      ->get('css.preprocess')));
  } catch (PdfEngineException $e) {
    drupal_set_message(new FormattableMarkup('Error generating PDF: ' . Xss::filter($e
      ->getMessage()), []), 'error');
    return new RedirectResponse($entity
      ->toUrl()
      ->toString());
  }
}