You are here

class PdfOrderFieldHandler in Commerce Invoice 7.2

@file Views field handler to display a download link for the current invoice on an order.

Hierarchy

  • class \Drupal\commerce_invoice_pdf\Views\PdfFieldHandler extends \Drupal\commerce_invoice_pdf\Views\views_handler_field

Expanded class hierarchy of PdfOrderFieldHandler

File

modules/pdf/src/Views/PdfOrderFieldHandler.php, line 10
Views field handler to display a download link for the current invoice on an order.

Namespace

Drupal\commerce_invoice_pdf\Views
View source
class PdfOrderFieldHandler extends PdfFieldHandler {

  /**
   * Overrides parent::render().
   */
  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'];
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PdfFieldHandler::options_form public function Overrides parent::options_form().
PdfFieldHandler::option_definition public function
PdfOrderFieldHandler::render public function Overrides parent::render(). Overrides PdfFieldHandler::render