@param $criteria

@return $this
@throws NotSupportedException
770782
protected function applyCriteria($criteria)
    {
        $query = $this->getQuery();
        $metadata = $this->getEntityMetadata();
        
        if (null !== $criteria) {
            switch (true) {
                case is_scalar($criteria):
                    $identifier = $metadata->getRawSQLName($metadata->getIdentifier());
                    $query->addConditions($identifier, $criteria);
                    break;
                
                case $criteria instanceof QueryBuilder\Select:
                    $criteria->setFromTable($metadata->getTableName());
                    $this->setQuery($criteria);
                    break;
                
                case (is_array($criteria) and count($criteria) > 0):
                    $query->addConditions(...$criteria);
                    break;
                
                default:
                    throw new NotSupportedException('It is impossible to determine the correct assignment criteria');
                    break;
            }
        }
        
        return $this;
    }
804081
public function getPaginator(Criteria $criteria = null) {
		if ($criteria === null) {
			$criteria = $this->query();
		}
		
		return new Paginator(new AdapterCriteria($criteria));
	}
1179061
public static function findByCriteria(array $criteria): ?Model\Collection
    {
        try {
            list($columns, $values, $options) = static::parseCriteria($criteria);
        } catch (NoTagsException $e) {
            return null;
        }

        if (\count($columns) < 1) {
            return static::findAll($options);
        }

        return static::findBy($columns, $values, $options);
    }
575554
protected function processBetweenFilter(Criteria $criteria, $field, $value)
    {
        if (is_array($value) && isset($value['start']) && isset($value['end'])) {

            $criteria->andWhere($criteria->expr()->andX(
                $criteria->expr()->gte($field, $value['start']),
                $criteria->expr()->lt($field, $value['end'])
            ));

        }

        return $this;
    }
72367
function criteria(array $criteria) {
		if ((list($left, $right) = each($criteria))) {
			$this->write("(");
			if (is_array($right)) {
				$this->criteria($right);
			} else {
				$this->write("(", $left, $this->param($right), ")");
			}
			while ((list($left, $right) = each($criteria))) {
				$this->write(is_int($left) && is_array($right) ? "OR" : "AND");
				if (is_array($right)) {
					$this->criteria($right);
				} else {
					$this->write("(", $left, $this->param($right), ")");
				}
			}
			$this->write(")");
		}
		return $this;
	}
678039
public function findOneBy(array $criteria)
    {
        $query = $this->createQueryBuilder($criteria);
        if (!($object = $this->getOneOrNullResultFromQueryBuilder($query))) {
            $this->throwException('The resource was not found', 'not-found');
        }
        return $object;
    }
365879
public function matching(Criteria $criteria)
    {
        $allEntities = $this->wrapped->findAll();
        $collection = new ArrayCollection($allEntities);

        return $collection->matching($criteria);
    }
230733
public function sortBy($criteria)
    {
        $criteria = $this->factoryCallableCriteria($criteria);
        $sorted   = $this->create();
        $groups   = $this->groupBy($criteria);

        $criterias = $this->map(function ($element, $key) use ($criteria) {
            return $criteria($element, $key);
        })->toArray();

        sort($criterias);
        $criterias = array_unique($criterias);

        foreach ($criterias as $key) {
            foreach ($groups[$key] as $element) {
                $sorted[] = $element;
            }
        }

        return $sorted;
    }
749252
public function remove(Closure $criteria)
    {
        foreach ($this->members as $k => $member) {
            if ($criteria($member)) {
                unset($this->members[$k]);
            }
        }
        $this->members = array_values($this->members);
        return $this;
    }
1107702
public function add(CriterionInterface $criterion): self
    {
        if (! $criterion->isAttached()) {
            $criterion->attach($this);
        }

        $this->criteria[] = $criterion;

        return $this;
    }
58117
public function findOne($criteria = array())
    {
        $model = $this->fetchCache($criteria);

        if (is_null($model)) {
            $cursor = $this->find($criteria);
            $model = $cursor->getNext();
            $this->rememberCache($criteria, $model);
        }

        return $model;
    }
936280
protected function findResourceOrThrowException(array $criteria)
    {
        if (null === $resource = $this->getRepository()->findOneBy($criteria)) {
            throw new NotFoundHttpException('Resource not found.');
        }
        return $resource;
    }
1310453
public function findOneBy(array $criteria)
    {
        $options = array('field' => key($criteria));
        $value = current($criteria);
        return $this->_sm->getUnitOfWork()->load($this->_class, $value, $options);
    }
1056965
public static function findOneEntityByCriteria(array $criteria = [], array $exclude = [])
    {
        $class = static::class;

        /** @var EntityRepository $obj_collection */
        $obj_collection = new $class();
        $obj_collection->setLimit(1);

        foreach ($criteria as $k => $v) {
            $obj_collection->addSimpleWhereField($k, $v);
        }

        foreach ($exclude as $k => $v) {
            $obj_collection->addWhereFieldIsNot($k, $v);
        }

        return $obj_collection->getFirstObjectFromCollection();
    }
1283278
public function addCriterion(Criterion $criterion)
    {
        $criterion->setDropzone($this);
        $this->peerReviewCriteria[] = $criterion;

        return $this;
    }
1165028
public function mergeCriteria(array $criteria)
    {
        $this->criteria = null === $this->criteria ? $criteria : array_merge($this->criteria, $criteria);

        return $this;
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }