You are here

class Condition in CiviCRM Entity 8.3

Implements entity query conditions for CiviCRM.

Hierarchy

Expanded class hierarchy of Condition

File

src/Entity/Query/CiviCRM/Condition.php, line 11

Namespace

Drupal\civicrm_entity\Entity\Query\CiviCRM
View source
class Condition extends ConditionBase {

  /**
   * The CiviCRM entity query object this condition belongs to.
   *
   * @var \Drupal\civicrm_entity\Entity\Query\CiviCRM\Query
   */
  protected $query;

  /**
   * {@inheritdoc}
   */
  public function compile($condition_container) {

    // If this is not the top level condition group then the sql query is
    // added to the $conditionContainer object by this function itself. The
    // SQL query object is only necessary to pass to Query::addField() so it
    // can join tables as necessary. On the other hand, conditions need to be
    // added to the $conditionContainer object to keep grouping.
    foreach ($this->conditions as $condition) {
      if ($condition['field'] instanceof ConditionInterface) {
        $query_condition = new static('AND', $this->query);
        $query_condition
          ->compile($condition_container);
      }
      else {
        $condition_container
          ->setParameter($condition['field'], $condition['value']);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function exists($field, $langcode = NULL) {
    return $this
      ->condition($field, NULL, 'IS NOT NULL', $langcode);
  }

  /**
   * {@inheritdoc}
   */
  public function notExists($field, $langcode = NULL) {
    return $this
      ->condition($field, NULL, 'IS NULL', $langcode);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Condition::$query protected property The CiviCRM entity query object this condition belongs to. Overrides ConditionFundamentals::$query
Condition::compile public function Compiles this conditional clause. Overrides ConditionInterface::compile
Condition::exists public function Queries for the existence of a field. Overrides ConditionInterface::exists
Condition::notExists public function Queries for the nonexistence of a field. Overrides ConditionInterface::notExists
ConditionBase::condition public function Adds a condition. Overrides ConditionInterface::condition
ConditionFundamentals::$conditions protected property Array of conditions.
ConditionFundamentals::$conjunction protected property The conjunction of this condition group. The value is one of the following:
ConditionFundamentals::$namespaces protected property List of potential namespaces of the classes belonging to this condition.
ConditionFundamentals::conditions public function
ConditionFundamentals::count public function
ConditionFundamentals::getConjunction public function
ConditionFundamentals::__clone public function Implements the magic __clone function.
ConditionFundamentals::__construct public function Constructs a Condition object.