public function PdfOrderFieldHandler::render in Commerce Invoice 7.2
Overrides parent::render().
Overrides PdfFieldHandler::render
File
- modules/
pdf/ src/ Views/ PdfOrderFieldHandler.php, line 15 - Views field handler to display a download link for the current invoice on an order.
Class
- PdfOrderFieldHandler
- @file Views field handler to display a download link for the current invoice on an order.
Namespace
Drupal\commerce_invoice_pdf\ViewsCode
public function render($values) {
$order_id = $this
->get_value($values);
$op = !empty($this->options['op']) ? $this->options['op'] : 'view';
// Mock order object, no need for the whole thing.
$order = new \stdClass();
$order->order_id = $order_id;
if ($invoice = commerce_invoice_load_current($order)) {
$link = [
'path' => 'invoices/' . $invoice->invoice_id . '/pdf',
];
if ($op === 'download') {
$link['query']['download'] = 1;
}
$this->options['alter']['make_link'] = TRUE;
$this->options['alter'] = array_merge($this->options['alter'], $link);
return $this->options['text'];
}
}