Finds elements in the scope of this element.

@param \PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria
@return Element[] array of instances of Se34\Element
197999
public function elements(\PHPUnit_Extensions_Selenium2TestCase_ElementCriteria $criteria)
	{
		$values = $this->postCommand('elements', $criteria);
		$elements = array();
		foreach ($values as $value)
		{
			$elements[] = static::fromResponseValue($value, $this->url->ascend(), $this->driver);
		}
		return $elements;
	}
148733
public function getAllUrls(array $criteria = [], $siteId = null): array
    {
        $urls = [];
        $elements = Craft::$app->getElements();
        $elementTypes = $elements->getAllElementTypes();
        foreach ($elementTypes as $elementType) {
            $urls = array_merge($urls, $this->getElementUrls($elementType, $criteria, $siteId));
        }

        return $urls;
    }
1207099
private function factoryCallableCriteria($criteria)
    {
        if (!$this->isCallable($criteria)) {
            $criteria = function ($element, $key) use ($criteria) {
                return $element->fetch($criteria);
            };
        }

        return $criteria;
    }
797939
public function findBy(
        array $criteria,
        ?array $orderBy = null,
        ?int $limit = null,
        ?int $offset = null
    ) : array {
        $objects = [];

        foreach ($this->objects as $object) {
            $matches = true;

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

                $matches = false;
            }

            if (! $matches) {
                continue;
            }

            $objects[] = $object;
        }

        return $objects;
    }
1098349
public static function findAllEntitiesByCriteria(array $criteria = [], array $exclude = []): array
    {
        $class = static::class;

        /** @var EntityRepository $obj_collection */
        $obj_collection = new $class();

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

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

        return $obj_collection->getAsArrayOfObjects();
    }
737697
public function findRecords(string $table, array $criteria = []): array
    {
        $url = $this->getEndpoint($table);

        if (count($criteria) > 0) {
            $formulas = [];
            foreach ($criteria as $field => $value) {
                $formulas[] = sprintf("%s='%s'", $field, $value);
            }

            $url .= sprintf(
                '?filterByFormula=(%s)',
                implode(' AND ', $formulas)
            );
        }

        /** @var Response $response */
        $response = $this->browser->get(
            $url,
            [
                'content-type' => 'application/json',
            ]
        );

        $data = json_decode($response->getContent(), true);

        return array_map(function (array $value) {
            return new Record($value['id'], $value['fields']);
        }, $data['records']);
    }
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;
    }
762768
protected function loadRows(IRowCriteria $criteria = null) : array
    {
        $objectSource = $this->objectSource;

        $objects          = null;
        $objectProperties = null;
        $definition       = $this->definition;

        if ($criteria) {
            $mappedCriteria = $this->criteriaMapper->mapCriteria($criteria);
            $objects        = $objectSource->matching($mappedCriteria);
        } else {
            $objects = $objectSource->getAll();
        }

        if ($objectProperties === null) {
            $objectProperties = $this->loadObjectProperties($objects);
        }

        return $this->mapObjectsToRows($definition, $objectProperties, $objects, $criteria);
    }
734215
public function findBy(
        array $criteria,
        ?array $orderBy = null,
        ?int $limit = null,
        ?int $offset = null
    ) : array {
        $rows = [];

        foreach ($this->getSourceRows() as $row) {
            if (! $this->matches($criteria, $row)) {
                continue;
            }

            $rows[] = $row;
        }

        if ($orderBy !== null && $orderBy !== []) {
            $rows = $this->sort($rows, $orderBy);
        }

        if ($limit !== null || $offset !== null) {
            return $this->slice($rows, $limit, $offset);
        }

        return $rows;
    }
168619
private function parseCriteria(array $criteria)
    {
        $out = '';
        if (!empty($criteria)) {
            $conditions = [];
            foreach ($criteria as $field => $value) {
                if (is_array($value)) {
                    $values = array_map(function($value) { return $this->connection->quote($value); }, $value);
                    $conditions[] = sprintf('%s IN (%s)', $field, implode(', ', $values));
                } else {
                    $operator = '=';
                    $ops = ['<>', '<', '>', '<=', '>='];
                    foreach ($ops as $op) {
                        if (false !== strpos($value, $op)) {
                            $operator = $op;
                            $value = str_replace(sprintf('%s ', $op), '', $value);
                            break;
                        }
                    }
                    $conditions[] = sprintf('%s %s %s', $field, $operator, $this->connection->quote($value));
                }
            }
            $out = sprintf(' WHERE %s', implode(' AND ', $conditions));
        }
        return $out;
    }
277808
public function find($criteria = [], array $fields = []) {
		$criteriaNormalized = $this->normalizeCriteria($criteria);
		
		$mongoCursor = $this->getAdapter()->find(
			$this->getTableName(),
			$criteriaNormalized,
			$fields
		);
		
		if ($criteria instanceof Criteria) {
			$this->applyCriteriaToCursor($criteria, $mongoCursor);
		}
		
		return $this->createResultset($mongoCursor);
	}
1246482
public function scanLocations(array $criteria)
    {
        $uris = $this->locations->map(function ($location) use ($criteria) {
            /** @var Location $location */
            return $location->getURI($criteria);
        })->filter(function ($uri) {
            return false !== $uri;
        });
        
        // Fall back for absolute paths on current filesystem.
        if ($uris->isEmpty()) {
            foreach ($criteria as $criterion) {
                if (file_exists($criterion)) {
                    return $criterion;
                }
            }
        }

        return $uris->isEmpty() ? false : $uris->first();
    }
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;
    }
90153
public function findOneBy($criteria)
    {
        $this->preFindOneBy();
        $entity =  $this->doFindOneBy($criteria);
        $this->postFindOneBy($entity);

        return $entity;
    }
333037
public function search(array $criteria = array())
    {
        $criteria['where'] = isset($criteria['where']) ? $criteria['where'] : '';
        if (isset($this->events[ self::EVENT_ON_BEFORE_SEARCH ])) {
            $this->secureEval($this->events[ self::EVENT_ON_BEFORE_SEARCH ], array(
                'criteria' => &$criteria
            ));
        }

        $results = $this->getDriver()->search($criteria);

        if (isset($this->events[ self::EVENT_ON_AFTER_SEARCH ])) {
            $this->secureEval($this->events[ self::EVENT_ON_AFTER_SEARCH ], array(
                'criteria' => &$criteria,
                'results' => &$results
            ));
        }

        return $results;
    }
1310453
public function findOneBy(array $criteria)
    {
        $options = array('field' => key($criteria));
        $value = current($criteria);
        return $this->_sm->getUnitOfWork()->load($this->_class, $value, $options);
    }
886864
public static function findOneByCriteria(array $criteria): ?self
    {
        try {
            list($columns, $values, $options) = static::parseCriteria($criteria);
        } catch (NoTagsException $e) {
            return null;
        }

        if (\count($columns) < 1) {
            return null;
        }

        return static::findOneBy($columns, $values, $options);
    }