You are here

public function Condition::__construct in Entity API 8

Constructs a new Condition object.

Parameters

string $field: The field, with an optional column name. E.g: 'uid', 'address.locality'.

mixed $value: The value.

string $operator: The operator. Possible values: =, <>, <, <=, >, >=, BETWEEN, NOT BETWEEN, IN, NOT IN, IS NULL, IS NOT NULL.

File

src/QueryAccess/Condition.php, line 53

Class

Condition
Represents a single query access condition.

Namespace

Drupal\entity\QueryAccess

Code

public function __construct($field, $value, $operator = NULL) {

  // Provide a default based on the data type of the value.
  if (!isset($operator)) {
    $operator = is_array($value) ? 'IN' : '=';
  }

  // Validate the selected operator.
  if (!in_array($operator, self::$supportedOperators)) {
    throw new \InvalidArgumentException(sprintf('Unrecognized operator "%s".', $operator));
  }
  $this->field = $field;
  $this->value = $value;
  $this->operator = $operator;
}