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);
            }
        }
    }
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);
            }
        }
    }
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 ) ; } } }
Populate a ReferenceMany association with a custom repository method.

@param PersistentCollectionInterface $collection

@return void
Populate a ReferenceMany association with a custom repository method .