You are here

Numeric.inc in EntityFieldQuery Views Backend 8

File

src/Plugin/views/filter/Numeric.inc
View source
<?php

/**
 * @file
 * Contains \Drupal\efq_views\Plugin\views\filter\Numeric.
 */
namespace Drupal\efq_views\Plugin\views\filter;

use Drupal\views\Plugin\views\filter\Numeric as ViewsNumeric;

/**
 * Numeric filter.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("efq_numeric")
 */
class Numeric extends ViewsNumeric {

  /**
   * We don't support every operator from the parent class ("not between", for example),
   * hence the need to define only the operators we do support.
   */
  function operators() {
    $operators = array(
      '<' => array(
        'title' => t('Is less than'),
        'method' => 'op_simple',
        'short' => t('<'),
        'values' => 1,
      ),
      '<=' => array(
        'title' => t('Is less than or equal to'),
        'method' => 'op_simple',
        'short' => t('<='),
        'values' => 1,
      ),
      '=' => array(
        'title' => t('Is equal to'),
        'method' => 'op_simple',
        'short' => t('='),
        'values' => 1,
      ),
      '<>' => array(
        'title' => t('Is not equal to'),
        'method' => 'op_simple',
        'short' => t('!='),
        'values' => 1,
      ),
      '>=' => array(
        'title' => t('Is greater than or equal to'),
        'method' => 'op_simple',
        'short' => t('>='),
        'values' => 1,
      ),
      '>' => array(
        'title' => t('Is greater than'),
        'method' => 'op_simple',
        'short' => t('>'),
        'values' => 1,
      ),
      'BETWEEN' => array(
        'title' => t('Is between'),
        'method' => 'op_between',
        'short' => t('between'),
        'values' => 2,
      ),
    );
    return $operators;
  }

  /**
   * {@inheritdoc}
   */
  function query() {
    $info = $this
      ->operators();
    if (!empty($info[$this->operator]['method'])) {
      $this
        ->{$info[$this->operator]['method']}($this->real_field);
    }
  }

}

Classes

Namesort descending Description
Numeric Numeric filter.