public function FractionField::clickSort in Fraction 8
Same name and namespace in other branches
- 2.x src/Plugin/views/field/FractionField.php \Drupal\fraction\Plugin\views\field\FractionField::clickSort()
Called to determine what to tell the clicksorter.
Overrides EntityField::clickSort
File
- src/
Plugin/ views/ field/ FractionField.php, line 26
Class
- FractionField
- Field handler for Fraction fields.
Namespace
Drupal\fraction\Plugin\views\fieldCode
public function clickSort($order) {
// Ensure the main table for this field is included.
$this
->ensureMyTable();
// Formula for calculating the final value, by dividing numerator by denominator.
// These are available as additional fields.
$formula = $this->tableAlias . '.' . $this->field . '_numerator / ' . $this->tableAlias . '.' . $this->field . '_denominator';
// Add the orderby.
$this->query
->addOrderBy(NULL, $formula, $order, $this->tableAlias . '_decimal');
}