Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

GroupByNumeric.php

Same filename in this branch
  1. 11.1.x core/modules/views/src/Plugin/views/argument/GroupByNumeric.php
  2. 11.1.x core/modules/views/src/Plugin/views/filter/GroupByNumeric.php

Namespace

Drupal\views\Plugin\views\sort

File

core/modules/views/src/Plugin/views/sort/GroupByNumeric.php

View source
<?php

namespace Drupal\views\Plugin\views\sort;

use Drupal\views\Attribute\ViewsSort;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\HandlerBase;
use Drupal\views\ViewExecutable;
use Drupal\views\Views;

/**
 * Handler for GROUP BY on simple numeric fields.
 */
class GroupByNumeric extends SortPluginBase {
    
    /**
     * The original handler.
     */
    protected HandlerBase $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));
    }

}

Classes

Title Deprecated Summary
GroupByNumeric Handler for GROUP BY on simple numeric fields.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal