Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / src / Plugin / views / sort / GroupByNumeric.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\sort;
4
5 use Drupal\views\Plugin\views\display\DisplayPluginBase;
6 use Drupal\views\ViewExecutable;
7 use Drupal\views\Views;
8
9 /**
10  * Handler for GROUP BY on simple numeric fields.
11  *
12  * @ViewsSort("groupby_numeric")
13  */
14 class GroupByNumeric extends SortPluginBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
20     parent::init($view, $display, $options);
21
22     // Initialize the original handler.
23     $this->handler = Views::handlerManager('sort')->getHandler($options);
24     $this->handler->init($view, $display, $options);
25   }
26
27   /**
28    * Called to add the field to a query.
29    */
30   public function query() {
31     $this->ensureMyTable();
32
33     $params = [
34       'function' => $this->options['group_type'],
35     ];
36
37     $this->query->addOrderBy($this->tableAlias, $this->realField, $this->options['order'], NULL, $params);
38   }
39
40   public function adminLabel($short = FALSE) {
41     return $this->getField(parent::adminLabel($short));
42   }
43
44 }