You are here

class EntityCondition in JSON:API 8

Same name and namespace in other branches
  1. 8.2 src/Query/EntityCondition.php \Drupal\jsonapi\Query\EntityCondition

A condition object for the EntityQuery.

@internal

Hierarchy

Expanded class hierarchy of EntityCondition

5 files declare their use of EntityCondition
EntityConditionNormalizer.php in src/Normalizer/EntityConditionNormalizer.php
EntityConditionNormalizerTest.php in tests/src/Kernel/Normalizer/EntityConditionNormalizerTest.php
EntityResourceTest.php in tests/src/Kernel/Controller/EntityResourceTest.php
FilterNormalizer.php in src/Normalizer/FilterNormalizer.php
TemporaryQueryGuard.php in src/Access/TemporaryQueryGuard.php

File

src/Query/EntityCondition.php, line 10

Namespace

Drupal\jsonapi\Query
View source
class EntityCondition {

  /**
   * The allowed condition operators.
   *
   * @var string[]
   */
  public static $allowedOperators = [
    '=',
    '<>',
    '>',
    '>=',
    '<',
    '<=',
    'STARTS_WITH',
    'CONTAINS',
    'ENDS_WITH',
    'IN',
    'NOT IN',
    'BETWEEN',
    'NOT BETWEEN',
    'IS NULL',
    'IS NOT NULL',
  ];

  /**
   * The field to be evaluated.
   *
   * @var string
   */
  protected $field;

  /**
   * The condition operator.
   *
   * @var string
   */
  protected $operator;

  /**
   * The value against which the field should be evaluated.
   *
   * @var mixed
   */
  protected $value;

  /**
   * Constructs a new EntityCondition object.
   */
  public function __construct($field, $value, $operator = NULL) {
    $this->field = $field;
    $this->value = $value;
    $this->operator = $operator ? $operator : '=';
  }

  /**
   * The field to be evaluated.
   *
   * @return string
   *   The field upon which to evaluate the condition.
   */
  public function field() {
    return $this->field;
  }

  /**
   * The comparison operator to use for the evaluation.
   *
   * For a list of allowed operators:
   *
   * @see \Drupal\jsonapi\Query\EntityCondition::allowedOperators
   *
   * @return string
   *   The condition operator.
   */
  public function operator() {
    return $this->operator;
  }

  /**
   * The value against which the condition should be evaluated.
   *
   * @return mixed
   *   The condition comparison value.
   */
  public function value() {
    return $this->value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityCondition::$allowedOperators public static property The allowed condition operators.
EntityCondition::$field protected property The field to be evaluated.
EntityCondition::$operator protected property The condition operator.
EntityCondition::$value protected property The value against which the field should be evaluated.
EntityCondition::field public function The field to be evaluated.
EntityCondition::operator public function The comparison operator to use for the evaluation.
EntityCondition::value public function The value against which the condition should be evaluated.
EntityCondition::__construct public function Constructs a new EntityCondition object.