@param string $collection

@return \Doctrine\ORM\QueryBuilder
425475
protected function select($collection)
    {
        $em      = $this->getEntityManager($collection);
        $builder = $em->createQueryBuilder();

        $builder->select('count(e)')->from($collection, 'e');

        return $builder;
    }
438916
public function updateCollection(Collection $collection): void
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->update('ngbm_collection')
            ->set('start', ':start')
            ->set('length', ':length')
            ->set('translatable', ':translatable')
            ->set('main_locale', ':main_locale')
            ->set('always_available', ':always_available')
            ->where(
                $query->expr()->eq('id', ':id')
            )
            ->setParameter('id', $collection->id, Type::INTEGER)
            ->setParameter('start', $collection->offset, Type::INTEGER)
            ->setParameter('length', $collection->limit, Type::INTEGER)
            ->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
            ->setParameter('main_locale', $collection->mainLocale, Type::STRING)
            ->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);

        $this->applyStatusCondition($query, $collection->status);

        $query->execute();
    }
1199170
public function createCursorForCollection(RepositoryCollection $collection)
    {
        $params = [];

        $sqlStatement = $this->getSqlStatementForCollection($collection, $params);
        $hasLimit = $sqlStatement->hasLimit();

        $sql = (string)$sqlStatement;

        if ($hasLimit){
            $sql = preg_replace("/^SELECT /", "SELECT SQL_CALC_FOUND_ROWS ", $sql);
        }

        $connection = static::getReadOnlyConnection();
        $statement = static::executeStatement((string)$sql, $params, $connection);

        $count = $statement->rowCount();

        if ($hasLimit){
            $count = static::returnSingleValue("SELECT FOUND_ROWS()", [], $connection);
        }

        $cursor = new MySqlCursor($statement, $this, $count, $collection->additionalColumns);
        // If the number of groups in the statement match those demanded by the collection we can then
        // assume that all grouping has executed in the repository. If not then we set the flag accordingly
        // so that the Collection class can manually group the rows later.
        $cursor->grouped = count($collection->getGroups()) == count($sqlStatement->groups);


        $filter = $collection->getFilter();

        if ($filter){
            $cursor->filtered = $filter->wasFilteredByRepository();
        }

        $cursor->setHydrationMappings($sqlStatement->potentialHydrationMappings);

        return $cursor;
    }
963679
private function resolveObject($collection, $id)
    {
        return $this->connection->selectCollection($this->databaseName, $collection)->findOne(['_id' => $id]);
    }
1227872
protected function getPublicationCollectionQueryParts($collection)
    {
        $queryParts = ['query' => '', 'params' => []];

        if (null === $collection) {
            $queryParts['query'] = 'p.collection IS NULL';
        } else {
            $queryParts['query'] = 'c.slug = :collection';
            $queryParts['params'] = ['collection' => $collection];
        }

        return $queryParts;
    }
566964
public function newObject($collection)
    {
        /** @var MongoObject $obj */
        $obj =$this->container->get($this->classMap->getClassForResult($collection, []));
        $obj->setCollection($collection);

        return $obj;
    }
1373148
public function transform($collection)
    {
        if (null === $collection) {
            return null;
        }

        if (!($collection instanceof Collection)) {
            throw new UnexpectedTypeException($collection, 'Doctrine\Common\Collection\Collection');
        }

        $results = array();
        foreach ($collection as $entity) {
            $results[] = $this->accessor->getValue($entity, $this->identifier);
        }

        //Here, do not put the result in the cache because we must check the value in
        //reverseTransform (by QueryBuilder)

        return $results;
    }
1325412
public function update(array $collection){
        foreach($collection as $key => $value){
            $this->collection[$key] = $value;
        }
        return $this;
    }
301619
public function reload($collection = null)
    {
        if ($collection === null) {
            $collection = $this->getCore();
        }

        return $this->collections()->reload($collection);
    }
1084248
public function prepareCollection(ProductCollection $collection)
    {
        $terms = $this->getQueryText();

        $collection->setSearchQuery($terms);

        return $collection;
    }
1324244
public function get($collection = "")
		{

			$documents = $this->getCursor($collection);

			$returns = array();

			if ($documents && !empty($documents)) {
				foreach ($documents as $doc) {
					$returns[] = $doc;
				}
			}

			return $returns;
		}
832705
public function createQuery(Query $query): Query
    {
        $dbQuery = $this->connection->createQueryBuilder()
            ->insert('ngbm_collection_query')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'collection_id' => ':collection_id',
                    'type' => ':type',
                ]
            )
            ->setValue(
                'id',
                $query->id !== null ?
                    (int) $query->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_collection_query')
            )
            ->setParameter('status', $query->status, Type::INTEGER)
            ->setParameter('collection_id', $query->collectionId, Type::INTEGER)
            ->setParameter('type', $query->type, Type::STRING);

        $dbQuery->execute();

        $query->id = $query->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_collection_query');

        return $query;
    }
1320431
public function setAll($collection) {
		foreach ($collection as $key => $element) {
			$this->set($key, $element);
		}
		
		return $this;
	}
6793
public function transform($collection)
    {
        if (null === $collection) {
            return null;
        }

        if (!($collection instanceof Collection)) {
            throw new UnexpectedTypeException($collection, 'Doctrine\Common\Collection\Collection');
        }

        $results = array();
        foreach ($collection as $entity) {
            $results[] = array(
                $this->arrayIdentifierName => $this->displayValue(
                    $this->accessor->getValue($entity, $this->identifier)
                ),
                $this->arrayLabelName => $this->displayValue($this->extractLabel($entity)),
            );
        }

        //Here, do not put the result in the cache because we must check the value in
        //reverseTransform (by QueryBuilder)
        return json_encode($results);
    }
1285994
public function materializeCollection($collection)
    {
        $materializedCollection = new Collection();
        foreach ($collection as $resource) {
            $materializedCollection->add($this->materialize($resource));
        }
        return $materializedCollection;
    }
733848
public function getByCriteria($collection, $criteria)
    {
        if ($data = $this->findOne($collection, $criteria)) {

            /** @var MongoObject $obj */
            $obj = $this->container->get(
                $this->classMap->getClassForResult($collection, $data)
            );
            $obj->setCollection($collection);
            $obj->loadFromArray($data);

            return $obj;
        }

        return null;
    }
325828
public function withCollection($collection, $transformer = null, $resourceKey = null)
    {
        return $this->respond(
            $this->getCollection($collection, $transformer, $resourceKey)
        );
    }