You are here

public function Condition::__toString in Entity API 8

Gets the string representation of the condition.

Used for debugging purposes.

Return value

string The string representation of the condition.

File

src/QueryAccess/Condition.php, line 97

Class

Condition
Represents a single query access condition.

Namespace

Drupal\entity\QueryAccess

Code

public function __toString() {
  if (in_array($this->operator, [
    'IS NULL',
    'IS NOT NULL',
  ])) {
    return "{$this->field} {$this->operator}";
  }
  else {
    if (is_array($this->value)) {
      $value = "['" . implode("', '", $this->value) . "']";
    }
    else {
      $value = "'" . $this->value . "'";
    }
    return "{$this->field} {$this->operator} {$value}";
  }
}