function commerce_invoice_pdf_create_worker in Commerce Invoice 7.2
1 string reference to 'commerce_invoice_pdf_create_worker'
- commerce_invoice_pdf_advanced_queue_info in modules/
pdf/ commerce_invoice_pdf.module - Implements hook_advanced_queue_info().
File
- modules/
pdf/ commerce_invoice_pdf.module, line 475 - The Commerce Invoice PDF module.
Code
function commerce_invoice_pdf_create_worker($item, $end_time = FALSE) {
$data = $item->data;
/** @var Invoice $invoice */
if ($invoice = entity_load_single('commerce_invoice', $data['invoice_id'])) {
_commerce_invoice_pdf_ensure_default_theme();
// Make sure that any entity_access() down the line returns TRUE.
global $user;
if ($user->uid !== $invoice->uid) {
$user = user_load($invoice->uid);
}
if (commerce_invoice_pdf_create($invoice, TRUE, $data['recreate'])) {
return array(
'status' => ADVANCEDQUEUE_STATUS_SUCCESS,
'result' => 'Processed ' . $item->item_id,
);
}
}
return array(
'status' => ADVANCEDQUEUE_STATUS_FAILURE,
'result' => 'Error processing queue item ' . $item->item_id,
);
}