You are here

class ViewsField in Commerce Invoice 7.2

Hierarchy

  • class \Drupal\commerce_invoice\InvoiceNumber\ViewsField extends \Drupal\commerce_invoice\InvoiceNumber\views_handler_field

Expanded class hierarchy of ViewsField

File

src/InvoiceNumber/ViewsField.php, line 9
Provides views field for invoice numbers.

Namespace

Drupal\commerce_invoice\InvoiceNumber
View source
class ViewsField extends \views_handler_field {

  /**
   * {@inheritdoc}
   */
  public function render($values) {
    $key = $this
      ->get_value($values, 'number_key');
    $sequence = $this
      ->get_value($values);
    $pattern_name = $this
      ->get_value($values, 'number_pattern');
    $invoiceNumber = new InvoiceNumber($sequence, $key, $pattern_name);
    return (string) $invoiceNumber;
  }

  /**
   * {@inheritdoc}
   */
  public function click_sort($order) {
    $params = $this->options['group_type'] != 'group' ? array(
      'function' => $this->options['group_type'],
    ) : array();
    $this->query
      ->add_orderby($this->table_alias, 'number_pattern', $order, '', $params);
    $this->query
      ->add_orderby($this->table_alias, 'number_key', $order, '', $params);
    $this->query
      ->add_orderby($this->table_alias, 'number_sequence', $order, '', $params);
  }

}

Members