class GroupByNumeric

Same name in this branch
  1. 9 core/modules/views/src/Plugin/views/filter/GroupByNumeric.php \Drupal\views\Plugin\views\filter\GroupByNumeric
  2. 9 core/modules/views/src/Plugin/views/argument/GroupByNumeric.php \Drupal\views\Plugin\views\argument\GroupByNumeric
Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/sort/GroupByNumeric.php \Drupal\views\Plugin\views\sort\GroupByNumeric
  2. 11.x core/modules/views/src/Plugin/views/filter/GroupByNumeric.php \Drupal\views\Plugin\views\filter\GroupByNumeric
  3. 11.x core/modules/views/src/Plugin/views/argument/GroupByNumeric.php \Drupal\views\Plugin\views\argument\GroupByNumeric

Handler for GROUP BY on simple numeric fields.

Plugin annotation

@ViewsSort("groupby_numeric");

Hierarchy

Expanded class hierarchy of GroupByNumeric

File

core/modules/views/src/Plugin/views/sort/GroupByNumeric.php, line 14

Namespace

Drupal\views\Plugin\views\sort
View source
class GroupByNumeric extends SortPluginBase {
  
  /**
   * The original handler.
   */
  protected $handler;
  
  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    // Initialize the original handler.
    $this->handler = Views::handlerManager('sort')->getHandler($options);
    $this->handler
      ->init($view, $display, $options);
  }
  
  /**
   * Called to add the field to a query.
   */
  public function query() {
    $this->ensureMyTable();
    $params = [
      'function' => $this->options['group_type'],
    ];
    $this->query
      ->addOrderBy($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
  }
  public function adminLabel($short = FALSE) {
    return $this->getField(parent::adminLabel($short));
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.