@param array $criteria

@return TemplateInterface[]
427232
public function findBy(array $criteria)
    {
        $found = [];
        foreach ($this->getCollection()->all() as $template) {
            foreach ($criteria as $criterium => $value) {
                $method = 'get'.ucfirst(strtolower($criterium));
                if (!method_exists($template, $method)) {
                    continue;
                }
                if ($template->$method() !== $value) {
                    continue 2;
                }
            }

            $found[] = $template;
        }

        return $found;
    }
365879
public function matching(Criteria $criteria)
    {
        $allEntities = $this->wrapped->findAll();
        $collection = new ArrayCollection($allEntities);

        return $collection->matching($criteria);
    }
1144153
public function getRandomOneBy(array $criteria)
    {
        $found = $this->getRandomBy($criteria, 1);
        if ([] === $found) {
            throw new \RuntimeException('Failed finding any Entities with this criteria');
        }
        $entity = current($found);
        if ($entity instanceof EntityInterface) {
            return $entity;
        }
        throw new \RuntimeException('Unexpected Entity Type ' . get_class($entity));
    }
922896
public function findOneBy(array $criteria)
    {
        $result = current($this->findBy($criteria, null, 1));

        return $result ? : null;
    }
420571
public function addCriteria(array $criteria)
    {
        foreach ($criteria as $key => $value) {
            $this->attr($key)->matches($value);
        }

        return $this;
    }
112973
protected function getParameters($criteria, array $parameters) {
    $result = [];
    // flatten conditions
    $criteriaFlat = [];
    foreach ($criteria as $key => $curCriteria) {
      foreach ($curCriteria as $criterion) {
        if ($criterion instanceof Criteria) {
          $mapper = self::getMapper($criterion->getType());
          $valueName = $criterion->getAttribute();
          $attributeDesc = $mapper->getAttribute($valueName);
          if ($attributeDesc) {
            $criteriaFlat[] = $criterion;
          }
        }
      }
    }
    // get parameters in order
    $criteriaValuePosition = [];
    foreach ($parameters as $placeholder => $index) {
      $value = $criteriaFlat[$index]->getValue();
      if (is_array($value)) {
        // criteria has array value
        // initialize position counting for this criteria (defined by index)
        if (!isset($criteriaValuePosition[$index])) {
          $criteriaValuePosition[$index] = 0;
        }
        // set the value from the array
        $result[$placeholder] = $value[$criteriaValuePosition[$index]];
        $criteriaValuePosition[$index]++;
      }
      else {
        // criteria has single value
        $result[$placeholder] = $value;
      }
    }
    return $result;
  }
315563
protected function loadData(IChartCriteria $criteria = null) : array
    {
        $criteria = $criteria ?: $this->criteria();

        $sections = $this->tableDataSource->load($this->criteriaMapper->mapCriteria($criteria))->getSections();

        if (empty($sections)) {
            return [];
        }

        // There will be no groupings so only one section
        /** @see ChartTableCriteriaMapper::mapCriteria */
        $tableRows = $sections[0]->getRows();
        $chartRows = [];

        foreach ($this->tableChartComponentIdMap as list($tableColumn, $columnComponent, $chartAxis, $axisComponent)) {
            /** @var string $tableColumn */
            /** @var string $columnComponent */
            /** @var string $chartAxis */
            /** @var string $axisComponent */
            foreach ($tableRows as $key => $tableRow) {
                $chartRows[$key][$chartAxis][$axisComponent] = $tableRow->getCellComponentData($tableColumn, $columnComponent);
            }
        }


        foreach ($this->componentIdCallableMap as list($chartAxis, $axisComponent, $callable)) {
            /** @var string $chartAxis */
            /** @var string $axisComponent */
            /** @var callable $callable */
            foreach ($tableRows as $key => $tableRow) {
                $chartRows[$key][$chartAxis][$axisComponent] = $callable($tableRow);
            }
        }

        return array_values($chartRows);
    }
726860
protected function loadRows(IRowCriteria $criteria = null) : array
    {
        $criteria = $criteria ?: $this->defaultLoadCriteria();

        $collection = Traversable::from($this->rows);

        /** @var ColumnConditionGroup[] $columnConditionGroups */
        $columnConditionGroups = $criteria->getConditionGroups();

        foreach ($columnConditionGroups as $columnConditionGroup) {
            if ($columnConditionGroup->getConditionMode() === IRowCriteria::CONDITION_MODE_AND) {
                foreach ($columnConditionGroup->getConditions() as $condition) {
                    $collection = $collection->where($condition->makeRowFilterCallable());
                }
            } else {
                $columnConditions = $columnConditionGroup->getConditions();
                $filterCallback   = array_shift($columnConditions)->makeRowFilterCallable();

                foreach ($columnConditionGroup->getConditions() as $condition) {
                    $conditionFilter = $condition->makeRowFilterCallable();
                    $filterCallback  = function ($row) use ($conditionFilter, $filterCallback) {
                        return $conditionFilter($row) || $filterCallback($row);
                    };
                }

                $collection = $collection->where($filterCallback);
            }
        }


        $orderings = $criteria->getOrderings();
        if (!empty($orderings)) {
            /** @var ColumnOrdering $firstOrdering */
            $firstOrdering = array_shift($orderings);
            $collection    = $collection->orderBy(
                $firstOrdering->makeComponentGetterCallable(),
                $firstOrdering->isAsc() ? Direction::ASCENDING : Direction::DESCENDING
            );

            foreach ($orderings as $ordering) {
                $collection = $collection->thenBy(
                    $ordering->makeComponentGetterCallable(),
                    $ordering->isAsc() ? Direction::ASCENDING : Direction::DESCENDING
                );
            }
        }

        $collection = $collection->slice($criteria->getRowsToSkip(), $criteria->getAmountOfRows());

        if (!$criteria->getWhetherLoadsAllColumns()) {
            $columnsToLoadMap = $criteria->getColumnsToLoad();

            $collection = $collection->select(function (TableRow $row) use ($columnsToLoadMap) {
                return new TableRow(array_intersect_key($row->getData(), $columnsToLoadMap));
            });
        }

        return $collection->asArray();
    }
1274783
public function createQuery(array $criteria = array())
    {
        $class = $this->documentClass.'Query';
        $query = new $class($this);
        $query->criteria($criteria);

        return $query;
    }
1254543
public function findBy(array $criteria = array(), array $orderBy = null, $limit = null, $offset = null)
    {
        return $this->findAll();
    }
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;
    }
262988
public function findOneBy(array $criteria): ?ResourceInterface
    {
        if (empty($criteria)) {
            throw new \InvalidArgumentException('The criteria array needs to be set.');
        }

        $results = $this->applyCriteria($this->findAll(), $criteria);

        if ($result = reset($results)) {
            return $result;
        }

        return null;
    }
292245
public function findOneBy(array $criteria)
    {
        $documents = $this->findBy($criteria, array(), 1);

        if ($documents instanceof ArrayCollection && count($documents)) {
            return $documents->first();
        }

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

        return $this;
    }
1028063
protected function validate_criteria($criteria) {
        $criteria = strtoupper($criteria);

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

        return $criteria;
    }
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;
    }
283
public function find($criteria = array())
    {
        if (!is_array($criteria)) {
            $criteria = array(
                '$id' => $criteria,
            );
        }

        // wrap criteria as NObject instance to make sure it can be override by hooks
        $criteria = new NObject($criteria);

        $this->applyHook('searching', $criteria);
        $cursor = $this->connection->query($this, $criteria->toArray());
        $this->applyHook('searched', $cursor);

        return $cursor;
    }