You are here

protected function InvoiceFileManager::generateInvoiceFile in Commerce Invoice 8.2

Generates a PDF file for the given invoice.

Parameters

\Drupal\commerce_invoice\Entity\InvoiceInterface $invoice: The invoice.

Return value

\Drupal\file\FileInterface|null The invoice file, NULL if the generation failed.

1 call to InvoiceFileManager::generateInvoiceFile()
InvoiceFileManager::getInvoiceFile in src/InvoiceFileManager.php
Download an invoice file.

File

src/InvoiceFileManager.php, line 96

Class

InvoiceFileManager
Default implementation of the invoice file manager.

Namespace

Drupal\commerce_invoice

Code

protected function generateInvoiceFile(InvoiceInterface $invoice) {
  try {

    /** @var \Drupal\entity_print\Plugin\PrintEngineInterface $print_engine */
    $print_engine = $this->pluginManager
      ->createSelectedInstance('pdf');
    return $this->printBuilder
      ->savePrintable($invoice, $print_engine);
  } catch (\Exception $e) {
    watchdog_exception('commerce_invoice', $e);
    return NULL;
  }
}