You are here

function commerce_invoice_pdf_action_create in Commerce Invoice 7.2

Rules action: Create a PDF file for a given invoice entity.

Parameters

Invoice $invoice: The invoice entity

boolean $recreate: Whether to recreate (replace) the file if it already exists.

boolean $queue: Whether to add the PDF creation into a queue or not.

1 string reference to 'commerce_invoice_pdf_action_create'
commerce_invoice_pdf_rules_action_info in modules/pdf/commerce_invoice_pdf.rules.inc
Implements hook_rules_action_info().

File

modules/pdf/commerce_invoice_pdf.rules.inc, line 79
Rules integration for the Commerce Invoice PDF module.

Code

function commerce_invoice_pdf_action_create(Invoice $invoice, $recreate, $queue = FALSE) {
  if (!$queue) {
    _commerce_invoice_pdf_ensure_default_theme();
    commerce_invoice_pdf_create($invoice, TRUE, $recreate);
  }
  else {
    $queue = DrupalQueue::get('commerce_invoice_pdf_create_queue');
    $task = array(
      'invoice_id' => $invoice->invoice_id,
      'recreate' => $recreate,
    );
    $queue
      ->createItem($task);
  }
}