Removes objects by a set of criteria.

@param array|Criteria $criteria
@return void
@throws \Doctrine\ORM\Query\QueryException
334456
public function deleteBy($criteria)
    {
        $criteria = Util::normalizeCriteria($criteria);

        $queryBuilder = $this->getQueryBuilder($criteria);
        $queryBuilder->delete($this->entityName, 'e');
        $queryBuilder->getQuery()->execute();
    }
271592
public function matching(Criteria $criteria) {
		if(!$this->baseRepository instanceof Selectable) {
			throw new \LogicException('The base repository does not implement Selectable.');
		}
		return $this->baseRepository->matching($criteria);
	}
292992
public function addCriteria(Criteria $criteria)
    {
        $allAliases = $this->getAllAliases();
        if (! isset($allAliases[0])) {
            throw new Query\QueryException('No aliases are set before invoking addCriteria().');
        }

        $visitor         = new QueryExpressionVisitor($this->getAllAliases());
        $whereExpression = $criteria->getWhereExpression();

        if ($whereExpression) {
            $this->andWhere($visitor->dispatch($whereExpression));
            foreach ($visitor->getParameters() as $parameter) {
                $this->parameters->add($parameter);
            }
        }

        if ($criteria->getOrderings()) {
            foreach ($criteria->getOrderings() as $sort => $order) {
                $hasValidAlias = false;
                foreach ($allAliases as $alias) {
                    if (strpos($sort . '.', $alias . '.') === 0) {
                        $hasValidAlias = true;
                        break;
                    }
                }

                if (! $hasValidAlias) {
                    $sort = $allAliases[0] . '.' . $sort;
                }

                $this->addOrderBy($sort, $order);
            }
        }

        $firstResult = $criteria->getFirstResult();
        $maxResults  = $criteria->getMaxResults();

        // Overwrite limits only if they was set in criteria
        if ($firstResult !== null) {
            $this->setFirstResult($firstResult);
        }
        if ($maxResults !== null) {
            $this->setMaxResults($maxResults);
        }

        return $this;
    }
1008714
public function applyFilter(Criteria $criteria, $filter)
    {
        if (!is_array($filter) || !is_array($this->filterable)) {
            return $criteria;
        }

        foreach ($this->filterable as $field) {
            if (array_key_exists($field, $filter)) {
                $this->processEqualFilter($criteria, $field, $filter[$field]);
                $this->processBetweenFilter($criteria, $field, $filter[$field]);
                $this->processOperatorFilter($criteria, $field, $filter[$field]);
            }
        }

        return $criteria;
    }
424069
public static function needsSelectAliases(Criteria $criteria)
    {
        $columnNames = array();
        foreach ($criteria->getSelectColumns() as $fullyQualifiedColumnName) {
            if ($pos = strrpos($fullyQualifiedColumnName, '.')) {
                $columnName = substr($fullyQualifiedColumnName, $pos);
                if (isset($columnNames[$columnName])) {
                    // more than one column with the same name, so aliasing is required
                    return true;
                }
                $columnNames[$columnName] = true;
            }
        }

        return false;
    }
10334
protected function processPagination(array $pagination, Criteria $criteria): void
    {
        if (isset($pagination['offset'])) {
            $criteria->setFirstResult((int) $pagination['offset']);
        }

        if (isset($pagination['limit'])) {
            $criteria->setMaxResults((int) $pagination['limit']);
        }
    }
1358726
public function findOne(array $criteria = [])
    {
        $result = $this->search($criteria);

        if (count($result) > 0) {
            return $result[0];
        }

        return null;
    }
1051120
protected function applyCriteriaToCursor(Criteria $criteria, MongoCursor $mongoCursor) {
		$sort   = $criteria->getSortConditions();
		$offset = $criteria->getOffset();
		$limit  = $criteria->getLimit();
				
		if (! empty($sort)) {
			$mongoCursor->sort($sort);
		}
		
		if ($offset !== null) {
			$mongoCursor->skip($offset);
		}

		if ($limit !== null) {
			$mongoCursor->limit($limit);
		}
	}
429768
public function remove($criteria) {

        $sql = 'DELETE FROM '.$this->name.' WHERE document_criteria("'.$this->database->registerCriteriaFunction($criteria).'", document)';

        return $this->database->connection->exec($sql);
    }
1028063
protected function validate_criteria($criteria) {
        $criteria = strtoupper($criteria);

        if(in_array($criteria, $this->available_criteria) === false) {
            throw new InvalidWhereQueryCriteriaException();
        }

        return $criteria;
    }
1181997
public function applyFilter(Criteria $criteria, $filter)
    {
        if (is_string($filter) && is_string($this->property)) {
            $criteria->andWhere(
                $criteria->expr()->contains($this->property, $filter)
            );
        }

        if (is_array($filter) && isset($filter[$this->searchKey])) {
            $criteria->andWhere(
                $criteria->expr()->contains($this->property, $filter[$this->searchKey])
            );
        }

        return $criteria;
    }
1198716
private function applyFilters() : void
    {
        foreach ($this->criteria as $criteria) {
            $filterClass = $criteria->getOperator();

            $filter = new $filterClass(
                $this->table->aliasField($criteria->getField()),
                $criteria->getValue()
            );

            $filter->apply($this->query);
        }
    }
329431
public function any(array $criteria) : self
    {
        $sql = [];
        $par = [];
        foreach ($criteria as $row) {
            if (isset($row[1])) {
                $temp = $this->filterSQL($row[0], $row[1] ?? null, $row[2] ?? false);
                $sql[] = $temp[0];
                $par = array_merge($par, $temp[1]);
            }
        }
        return $this->where('(' . implode(' OR ', $sql) . ')', $par);
    }
150206
private function applyCriteriaToQueryBuilder(array $criteria, QueryBuilder $qb)
    {
        foreach ($criteria as $key => $value) {
            if (in_array($key, ['treeId', 'teaserId', 'eid', 'version'])) {
                $qb->andWhere($qb->expr()->eq("h.$key", $value));
            } elseif (in_array($key, ['language', 'action'])) {
                $qb->andWhere($qb->expr()->eq("h.$key", $qb->expr()->literal($value)));
            } elseif (in_array($key, ['comment'])) {
                $qb->andWhere($qb->expr()->like("h.$key", $qb->expr()->literal("%$value%")));
            } else {
                throw new InvalidArgumentException("Unkown field $key");
            }
        }
    }
23859
public function findOneBy(array $criteria) : ?array
    {
        foreach ($this->objects as $object) {
            $matches = true;

            foreach ($criteria as $key => $value) {
                if ($object[$key] === $value) {
                    continue;
                }

                $matches = false;
            }

            if ($matches) {
                return $object;
            }
        }

        return null;
    }
1291945
private function filterHasEncryptedField(array $criteria)
    {
        $result = false;

        if (!empty($criteria)) {
            $encryptedFields = array_keys($this->getEncryptedFields());
            $criteriaFields = array_keys($criteria);
            $commonFields = array_intersect($encryptedFields, $criteriaFields);

            $result = !empty($commonFields);
        }

        return $result;
    }
832304
protected void prepareCriteria(Criteria criteria) {
		if (isCacheQueries()) {
			criteria.setCacheable(true);
			if (getQueryCacheRegion() != null) {
				criteria.setCacheRegion(getQueryCacheRegion());
			}
		}
		if (getFetchSize() > 0) {
			criteria.setFetchSize(getFetchSize());
		}
		if (getMaxResults() > 0) {
			criteria.setMaxResults(getMaxResults());
		}
	}