You are here

class Condition in Search API 8

Represents a single (field operator value) condition in a search query.

Hierarchy

Expanded class hierarchy of Condition

6 files declare their use of Condition
AllTermsArgumentTest.php in tests/src/Unit/Views/AllTermsArgumentTest.php
FieldsProcessorPluginBaseTest.php in tests/src/Unit/Processor/FieldsProcessorPluginBaseTest.php
HtmlFilterTest.php in tests/src/Unit/Processor/HtmlFilterTest.php
IgnoreCaseTest.php in tests/src/Unit/Processor/IgnoreCaseTest.php
IgnoreCharacterTest.php in tests/src/Unit/Processor/IgnoreCharacterTest.php

... See full list

File

src/Query/Condition.php, line 8

Namespace

Drupal\search_api\Query
View source
class Condition implements ConditionInterface {

  /**
   * The field this condition checks.
   *
   * @var string
   */
  protected $field;

  /**
   * The value being compared to the field.
   *
   * @var mixed
   */
  protected $value;

  /**
   * The operator that combined field and value in this condition.
   *
   * @var string
   */
  protected $operator;

  /**
   * Constructs a Condition object.
   *
   * @param string $field
   *   The field this condition checks.
   * @param mixed $value
   *   The value being compared to the field.
   * @param string $operator
   *   (optional) The operator that combined field and value in this condition.
   */
  public function __construct($field, $value, $operator = '=') {
    $this->field = $field;
    $this->value = $value;
    $this->operator = $operator;
  }

  /**
   * {@inheritdoc}
   */
  public function getField() {
    return $this->field;
  }

  /**
   * {@inheritdoc}
   */
  public function setField($field) {
    $this->field = $field;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getValue() {
    return $this->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setValue($value) {
    $this->value = $value;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getOperator() {
    return $this->operator;
  }

  /**
   * {@inheritdoc}
   */
  public function setOperator($operator) {
    $this->operator = $operator;
    return $this;
  }

  /**
   * Implements the magic __toString() method to simplify debugging.
   */
  public function __toString() {
    return "{$this->field} {$this->operator} " . str_replace("\n", "\n    ", var_export($this->value, TRUE));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Condition::$field protected property The field this condition checks.
Condition::$operator protected property The operator that combined field and value in this condition.
Condition::$value protected property The value being compared to the field.
Condition::getField public function Retrieves the field. Overrides ConditionInterface::getField
Condition::getOperator public function Retrieves the operator. Overrides ConditionInterface::getOperator
Condition::getValue public function Retrieves the value. Overrides ConditionInterface::getValue
Condition::setField public function Sets the field. Overrides ConditionInterface::setField
Condition::setOperator public function Sets the operator. Overrides ConditionInterface::setOperator
Condition::setValue public function Sets the value. Overrides ConditionInterface::setValue
Condition::__construct public function Constructs a Condition object.
Condition::__toString public function Implements the magic __toString() method to simplify debugging.