Skip to content
GroupByNumeric.php 1.01 KiB
Newer Older
Earl Miles's avatar
Earl Miles committed
<?php

/**
 * @file
 * Definition of Drupal\views\Plugin\views\sort\GroupByNumeric.
namespace Drupal\views\Plugin\views\sort;
use Drupal\Core\Annotation\Plugin;
Earl Miles's avatar
Earl Miles committed
/**
 * Handler for GROUP BY on simple numeric fields.
 *
Bram Goffings's avatar
Bram Goffings committed
 *   id = "groupby_numeric"
class GroupByNumeric extends SortPluginBase {
  public function init(ViewExecutable $view, &$options) {
Earl Miles's avatar
Earl Miles committed
    parent::init($view, $options);

    // Initialize the original handler.
    $this->handler = views_get_handler($options['table'], $options['field'], 'sort');
    $this->handler->init($view, $options);
  }

  /**
   * Called to add the field to a query.
   */
Earl Miles's avatar
Earl Miles committed

    $params = array(
      'function' => $this->options['group_type'],
    );

    $this->query->add_orderby($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
  public function adminLabel($short = FALSE) {
    return $this->getField(parent::adminLabel($short));