Initializes (loads) an uninitialized persistent collection of an entity.

@param PersistentCollection $collection The collection to initialize.

@todo Maybe later move to EntityManager#initialize($proxyOrCollection). See DDC-733.
166227
public function loadCollection(PersistentCollection $collection)
    {
        $association = $collection->getMapping();
        $persister   = $this->getEntityPersister($association->getTargetEntity());

        if ($association instanceof OneToManyAssociationMetadata) {
            $persister->loadOneToManyCollection($association, $collection->getOwner(), $collection);
        } else {
            $persister->loadManyToManyCollection($association, $collection->getOwner(), $collection);
        }

        $collection->setInitialized(true);
    }
1224671
public function initChildren()
    {
        if ($this->parentNode) {
            $this->children = new Collection(
                $this->parentNode->children->idList, // idlist as reference
                $this->parentNode->children->keyList // keylist as reference
            );
        } else {
            $this->children = new Collection();
        }
    }
322498
public function intersect(AbstractCollection $collection)
    {
        if (get_class($this) === get_class($collection)) {
            $newData = array_intersect($this->dataPlaceHolder, $collection->getDataPlaceHolder());

            return new static($newData);
        } else {
            $msg = "Intersection may apply only on two collections of the same type.";
            throw new InvalidArgumentException($msg);
        }
    }
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);
                }
            }
        }
    }
1062701
public function spawn($name, Collection $collection)
    {
        $nb = new self($name, $this->conf);
        $nb->takeCollection($collection);

        return $nb;
    }
554330
public function initializeObject($obj)
    {
        if ($obj instanceof Proxy) {
            $obj->__load();
        } elseif ($obj instanceof PersistentCollectionInterface) {
            $obj->initialize();
        }
    }
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);
            }
        }
    }
1241626
public function setDocumentPersister(string $documentName, Persisters\DocumentPersister $persister) : void
    {
        $this->persisters[$documentName] = $persister;
    }
13716
protected function load($group, $namespace, $collection)
    {
        $env = $this->environment;

        if (isset($this->items[$collection])) {
            return;
        }

        $items = $this->loader->load($env, $group, $namespace);

        if (isset($this->afterLoad[$namespace])) {
            $items = $this->callAfterLoad($namespace, $group, $items);
        }

        $this->items[$collection] = $items;
    }
53317
protected function collection_query( &$collection ) 
	{
		$local_keys = array();
		
		foreach( $collection as $item )
		{
			$local_keys[] = $item->raw( $this->local_key );
		}
		
		// set the correct collection where
		$this->query->wheres = array();
		$this->query->where( $this->foreign_key, 'in', $local_keys );
		$this->query->group_result( $this->foreign_key );
		
		$this->query->limit( null );
	}
200244
protected function initialize()
    {
        $this->id = $this->formatId($this->column);
        $this->group = new Collection();
        $this->name = "{$this->id}-filter-group";

        $this->setupDefaultPresenter();
    }
1197453
public function createCursorForCollection(RepositoryCollection $collection)
    {
        $ids = array_keys($this->cachedObjectData);

        return new UniqueIdentifierListCursor(array_values($ids), $this->modelClassName);
    }
1180573
public function decorate(Collection $collection)
    {
        if ($this->storeManager->isSingleStoreMode()) {
            return;
        }

        $this->addLinkedWebsiteIds($collection);
        $this->ensureWebsiteLinkedSet($collection);
    }
117891
public function initializeObject(object $obj) : void
    {
        if ($obj instanceof GhostObjectInterface) {
            $obj->initializeProxy();
        } elseif ($obj instanceof PersistentCollectionInterface) {
            $obj->initialize();
        }
    }
766492
private function addManyReferences(PersistentCollectionInterface $persistentCollection)
    {
        $mapping = $persistentCollection->getMapping();
        $ap = $this->dm->getUnitOfWork()->getAssociationPersister();

        foreach ($persistentCollection->getRawData() as $reference) {
            /** @var Identifier $identifier */
            $identifier = $ap->loadReference($mapping, $reference);
            $document   = $this->uow->tryGetByIdentifier($identifier);

            if ($document === false || ($document instanceof Proxy && !$document->__isInitialized())) {
                $className = $identifier->class->getName();
                $key       = serialize($identifier);

                $this->groupedIds[$className][$key] = $identifier;
            }
        }
    }
289629
public function setCollection($collection)
    {
        $this->indexedContainer = $collection;

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

        return $this;
    }
979029
public function initializeObject($obj)
    {
        if ($obj instanceof Proxy) {
            $obj->__load();

            return;
        }

        if ($obj instanceof PersistentCollection) {
            $obj->initialize();
        }
    }