You are here

protected function Condition::merge in MongoDB 8

1 call to Condition::merge()
Condition::compile in src/Entity/Condition.php
Compiles this conditional clause.

File

src/Entity/Condition.php, line 146
Contains Drupal\mongodb\Entity\ContentEntityStorage.

Class

Condition

Namespace

Drupal\mongodb\Entity

Code

protected function merge(&$old_array, $new_value) {

  // @TODO this doesnt work with regexps.
  list($op, $value) = each($new_value);
  if (isset($old_array[$op])) {
    $old_value = $old_array[$op];
    switch ($op) {
      case '$eq':
        if ($value !== $new_value) {

          // Impossible condition.
          $old_array = [
            '$gt' > new \MongoMaxKey(),
          ];
        }
        break;
      case '$in':
      case '$nin':
        $old_array[$op] = array_unique(array_merge($old_value, $value));
        break;
    }
  }
  else {
    $old_array[$op] = $value;
  }
}