@param PersistentCollection $collection

@return Cursor
357172
public function createReferenceManyWithRepositoryMethodCursor(PersistentCollection $collection)
    {
        $hints = $collection->getHints();
        $mapping = $collection->getMapping();
        $cursor = $this->dm->getRepository($mapping['targetDocument'])
            ->$mapping['repositoryMethod']($collection->getOwner());

        if (isset($mapping['sort'])) {
            $cursor->sort($mapping['sort']);
        }
        if (isset($mapping['limit'])) {
            $cursor->limit($mapping['limit']);
        }
        if (isset($mapping['skip'])) {
            $cursor->skip($mapping['skip']);
        }
        if ( ! empty($hints[Query::HINT_SLAVE_OKAY])) {
            $cursor->slaveOkay(true);
        }
        if ( ! empty($hints[Query::HINT_READ_PREFERENCE])) {
            $cursor->setReadPreference($hints[Query::HINT_READ_PREFERENCE], $hints[Query::HINT_READ_PREFERENCE_TAGS]);
        }

        return $cursor;
    }
374137
private function loadReferenceManyWithRepositoryMethod(PersistentCollectionInterface $collection)
    {
        $iterator  = $this->createReferenceManyWithRepositoryMethodIterator($collection);
        $mapping   = $collection->getMapping();
        $documents = $iterator->toArray();
        foreach ($documents as $key => $obj) {
            if ($mapping->type === Type::MAP) {
                $collection->set($key, $obj);
            } else {
                $collection->add($obj);
            }
        }
    }
617094
public function intersect($collection)
    {
        $intersection = new DefaultCollection();
        /** @var ModelInterface $localModel */
        foreach ($this as $localModel) {
            /** @var ModelInterface $otherModel */
            foreach ($collection as $otherModel) {
                if (($localModel->getProviderName() === $otherModel->getProviderName())
                    && ($localModel->getId() === $otherModel->getId())
                ) {
                    $intersection->push($localModel);
                }
            }
        }

        return $intersection;
    }
660072
protected function getDeleteRowSQL(PersistentCollection $collection)
    {
        $association = $collection->getMapping();
        $class       = $this->em->getClassMetadata($association->getSourceEntity());
        $targetClass = $this->em->getClassMetadata($association->getTargetEntity());
        $columns     = [];
        $types       = [];

        $joinTable     = $association->getJoinTable();
        $joinTableName = $joinTable->getQuotedQualifiedName($this->platform);

        foreach ($joinTable->getJoinColumns() as $joinColumn) {
            /** @var JoinColumnMetadata $joinColumn */
            $quotedColumnName     = $this->platform->quoteIdentifier($joinColumn->getColumnName());
            $referencedColumnName = $joinColumn->getReferencedColumnName();

            if (! $joinColumn->getType()) {
                $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $class, $this->em));
            }

            $columns[] = $quotedColumnName;
            $types[]   = $joinColumn->getType();
        }

        foreach ($joinTable->getInverseJoinColumns() as $joinColumn) {
            /** @var JoinColumnMetadata $joinColumn */
            $quotedColumnName     = $this->platform->quoteIdentifier($joinColumn->getColumnName());
            $referencedColumnName = $joinColumn->getReferencedColumnName();

            if (! $joinColumn->getType()) {
                $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em));
            }

            $columns[] = $quotedColumnName;
            $types[]   = $joinColumn->getType();
        }

        return [
            sprintf('DELETE FROM %s WHERE %s = ?', $joinTableName, implode(' = ? AND ', $columns)),
            $types,
        ];
    }
192156
private function setCollection(PersistentCollectionInterface $coll)
    {
        list($qb, $path, $parent) = $this->getQueryPathAndParent($coll);

        $coll->initialize();

        $path->set($coll);
        $this->executeQuery($qb, $parent);
    }
841032
public function renumberCollection(Collection $collection)
    {
        $i = 0;

        foreach ( $collection as $item ) {
            if ( $item instanceof NumericallySortableContract ) {
                $item->updateSortingOrder(++$i);
            }
        }

        return $this;
    }
309912
public function grabFromCollection($collection, $criteria = [])
    {
        $collection = $this->driver->getDbh()->selectCollection($collection);
        return $collection->findOne($criteria);
    }
1148332
public function persist($collection, array $document)
    {
        

        if ($collection instanceof Collection) {
            $collectionName = $collection->getName();
        } else {
            $collectionName = $collection;
            $collection = static::factory($collection);
        }
        
        $data = $this->marshall($document);
        $result = false;

        
        if (!isset($document['$id'])) {
            $id = $this->insert($collectionName, $data);
            if ($id) {
                $data['$id'] = $id;
                $result = $data;
            }
        } else {
            $data['id'] = $document['$id'];
            unset($data['$id']);
            $result = $this->update($collectionName, $data);

            if ($result) {
                $result = $data;
            }
        }

        return $this->unmarshall($result);
    }
1091225
private function trackCollection(Collection $collection)
    {
        $blocks = $collection->getBlocks();
        $this->trackBlocks($collection, $blocks);

        $attributes = $collection->getSetCollectionAttributes();
        $this->trackAttributes($collection, $attributes);
    }
765038
protected function getDeleteSQLParameters(PersistentCollection $collection)
    {
        $association = $collection->getMapping();
        $identifier  = $this->uow->getEntityIdentifier($collection->getOwner());
        $joinTable   = $association->getJoinTable();
        $joinColumns = $joinTable->getJoinColumns();

        // Optimization for single column identifier
        if (count($joinColumns) === 1) {
            return [reset($identifier)];
        }

        // Composite identifier
        $sourceClass = $this->em->getClassMetadata($association->getSourceEntity());
        $params      = [];

        foreach ($joinColumns as $joinColumn) {
            $params[] = $identifier[$sourceClass->fieldNames[$joinColumn->getReferencedColumnName()]];
        }

        return $params;
    }
1083077
public function ddl(Collection $collection)
    {
        if (!empty($this->options['autoddl'])) {
            $sql = $this->dialect->grammarDDL($collection, $this->options['autoddl']);

            $this->execute($sql);
        }
    }
739645
public function getPersistentCollectionGenerator()
    {
        if (!isset($this->odmOptions['persistentCollectionGenerator'])) {
            $this->odmOptions['persistentCollectionGenerator'] = new DefaultPersistentCollectionGenerator(
                $this->getPersistentCollectionDir(),
                $this->getPersistentCollectionNamespace()
            );
        }

        return $this->odmOptions['persistentCollectionGenerator'];
    }
14457
private function loadEmbedManyCollection(PersistentCollectionInterface $collection)
    {
        $rawData = $collection->getRawData();

        if ($rawData) {
            $mapping = $collection->getMapping();
            $owner   = $collection->getOwner();

            foreach ($rawData as $key => $data) {
                if ($mapping->type === Type::MAP) {
                    $key = (string)$key;
                } else {
                    $key = (int)$key;
                }

                $embeddedDocument = $this->uow->getAssociationPersister()->loadEmbed($mapping, $data, $owner, $key, $collection->isReadOnly());

                if ($mapping->type === Type::MAP) {
                    $collection->set($key, $embeddedDocument);
                } else {
                    $collection->add($embeddedDocument);
                }
            }
        }
    }
289629
public function setCollection($collection)
    {
        $this->indexedContainer = $collection;

        foreach ($collection as $argModel) {
            $this->hashedContainer[$argModel->getName()] = $argModel;
        }

        return $this;
    }
616720
public function postCollectionLoad(PersistentCollectionInterface $coll) : void
    {
        $eventArgs = new PostCollectionLoadEventArgs($coll, $this->dm);
        $this->evm->dispatchEvent(Events::postCollectionLoad, $eventArgs);
    }
1209370
public function getKeys($collection)
    {
        $cursor = $this->server->executeQuery($this->database . '.' . $collection,
            new \MongoDb\Driver\Query([], ['limit' => 1]));

        $result = current($cursor->toArray());

        $this->queriesResultCache[ 'collectionKeys' ][ $collection ] = [];

        foreach (get_object_vars($result) as $key => $value) {
            $this->queriesResultCache[ 'collectionKeys' ][ $collection ][] = $key;
        }

        return $this->queriesResultCache[ 'collectionKeys' ][ $collection ];
    }
1045797
public function intersect( common_Collection $collection)
    {
        $returnValue = null;

        
         $returnValue = new core_kernel_classes_ContainerCollection(new common_Object(__METHOD__));
         $returnValue->sequence = array_uintersect($this->sequence, $collection->sequence, 'core_kernel_classes_ContainerComparator::compare');
        

        return $returnValue;
    }