function Condition::__clone

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::__clone()
  2. 10 core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::__clone()
  3. 11.x core/lib/Drupal/Core/Database/Query/Condition.php \Drupal\Core\Database\Query\Condition::__clone()

PHP magic __clone() method.

Only copies fields that implement Drupal\Core\Database\Query\ConditionInterface. Also sets $this->changed to TRUE.

File

core/lib/Drupal/Core/Database/Query/Condition.php, line 365

Class

Condition
Generic class for a series of conditions in a query.

Namespace

Drupal\Core\Database\Query

Code

public function __clone() {
    $this->changed = TRUE;
    foreach ($this->conditions as $key => $condition) {
        if ($key !== '#conjunction') {
            if ($condition['field'] instanceof ConditionInterface) {
                $this->conditions[$key]['field'] = clone $condition['field'];
            }
            if ($condition['value'] instanceof SelectInterface) {
                $this->conditions[$key]['value'] = clone $condition['value'];
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.