3 namespace Drupal\Core\Entity\Query;
6 * Common code for all implementations of the entity query condition interfaces.
8 abstract class ConditionFundamentals {
11 * Array of conditions.
15 protected $conditions = [];
18 * The conjunction of this condition group. The value is one of the following:
25 protected $conjunction;
28 * The query this condition belongs to.
30 * @var \Drupal\Core\Entity\Query\QueryInterface
35 * List of potential namespaces of the classes belonging to this condition.
39 protected $namespaces = [];
42 * Constructs a Condition object.
44 * @param string $conjunction
45 * The operator to use to combine conditions: 'AND' or 'OR'.
46 * @param QueryInterface $query
47 * The entity query this condition belongs to.
48 * @param array $namespaces
49 * List of potential namespaces of the classes belonging to this condition.
51 public function __construct($conjunction, QueryInterface $query, $namespaces = []) {
52 $this->conjunction = $conjunction;
53 $this->query = $query;
54 $this->namespaces = $namespaces;
60 public function getConjunction() {
61 return $this->conjunction;
67 public function count() {
68 return count($this->conditions) - 1;
74 public function &conditions() {
75 return $this->conditions;
79 * Implements the magic __clone function.
81 * Makes sure condition groups are cloned as well.
83 public function __clone() {
84 foreach ($this->conditions as $key => $condition) {
85 if ($condition['field'] instanceof ConditionInterface) {
86 $this->conditions[$key]['field'] = clone($condition['field']);