public function primeReferences(ClassMetadata $class, $documents, $attributeName, $refresh, $readOnly, $primer = null)
    {
        $data          = $this->parseDotSyntaxForPrimer($attributeName, $class, $documents);
        $mapping       = $data['mapping'];
        $attributeName = $data['attributeName'];
        $class         = $data['class'];
        $documents     = $data['documents'];

        /* Inverse-side references would need to be populated before we can
         * collect references to be primed. This is not supported.
         */
        if (!$mapping->reference || !$mapping->isOwningSide) {
            throw new \InvalidArgumentException(sprintf('Attribute "%s" is not the owning side of a reference relationship in class "%s"', $attributeName, $class->name));
        }

        if ($primer !== null && !is_callable($primer)) {
            throw new \InvalidArgumentException('$primer is not callable');
        }

        $primer = $primer ?: $this->defaultPrimer;

        /** @var PersistentCollectionInterface $document */
        foreach ($documents as $document) {
            $value = $class->getAttributeValue($document, $attributeName);

            /* The attribute will need to be either a Proxy (reference-one) or
             * PersistentCollection (reference-many) in order to prime anything.
             */
            if (!is_object($value)) {
                continue;
            }

            if ($mapping->isOne() && $value instanceof Proxy && !$value->__isInitialized()) {
                $identifier = $this->uow->getDocumentIdentifier($value);
                $className  = $identifier->class->getName();

                $this->groupedIds[$className][$identifier->getSerialized()] = $identifier;
            } elseif ($mapping->isMany() && $value instanceof PersistentCollectionInterface) {
                $this->addManyReferences($value);
            }
        }

        foreach ($this->groupedIds as $className => $ids) {
            $class = $this->dm->getClassMetadata($className);

            call_user_func($primer, $this->dm, $class, array_values($ids), $refresh, $readOnly);
        }
    }
public function primeReferences(ClassMetadata $class, $documents, $attributeName, $refresh, $readOnly, $primer = null)
    {
        $data          = $this->parseDotSyntaxForPrimer($attributeName, $class, $documents);
        $mapping       = $data['mapping'];
        $attributeName = $data['attributeName'];
        $class         = $data['class'];
        $documents     = $data['documents'];

        /* Inverse-side references would need to be populated before we can
         * collect references to be primed. This is not supported.
         */
        if (!$mapping->reference || !$mapping->isOwningSide) {
            throw new \InvalidArgumentException(sprintf('Attribute "%s" is not the owning side of a reference relationship in class "%s"', $attributeName, $class->name));
        }

        if ($primer !== null && !is_callable($primer)) {
            throw new \InvalidArgumentException('$primer is not callable');
        }

        $primer = $primer ?: $this->defaultPrimer;

        /** @var PersistentCollectionInterface $document */
        foreach ($documents as $document) {
            $value = $class->getAttributeValue($document, $attributeName);

            /* The attribute will need to be either a Proxy (reference-one) or
             * PersistentCollection (reference-many) in order to prime anything.
             */
            if (!is_object($value)) {
                continue;
            }

            if ($mapping->isOne() && $value instanceof Proxy && !$value->__isInitialized()) {
                $identifier = $this->uow->getDocumentIdentifier($value);
                $className  = $identifier->class->getName();

                $this->groupedIds[$className][$identifier->getSerialized()] = $identifier;
            } elseif ($mapping->isMany() && $value instanceof PersistentCollectionInterface) {
                $this->addManyReferences($value);
            }
        }

        foreach ($this->groupedIds as $className => $ids) {
            $class = $this->dm->getClassMetadata($className);

            call_user_func($primer, $this->dm, $class, array_values($ids), $refresh, $readOnly);
        }
    }
public function primeReferences ( ClassMetadata $ class , $ documents , $ attributeName , $ refresh , $ readOnly , $ primer = null ) { $ data = $ this -> parseDotSyntaxForPrimer ( $ attributeName , $ class , $ documents ) ; $ mapping = $ data [ 'mapping' ] ; $ attributeName = $ data [ 'attributeName' ] ; $ class = $ data [ 'class' ] ; $ documents = $ data [ 'documents' ] ; /* Inverse-side references would need to be populated before we can
         * collect references to be primed. This is not supported.
         */ if ( ! $ mapping -> reference || ! $ mapping -> isOwningSide ) { throw new \ InvalidArgumentException ( sprintf ( 'Attribute "%s" is not the owning side of a reference relationship in class "%s"' , $ attributeName , $ class -> name ) ) ; } if ( $ primer !== null && ! is_callable ( $ primer ) ) { throw new \ InvalidArgumentException ( '$primer is not callable' ) ; } $ primer = $ primer ? : $ this -> defaultPrimer ; /** @var PersistentCollectionInterface $document */ foreach ( $ documents as $ document ) { $ value = $ class -> getAttributeValue ( $ document , $ attributeName ) ; /* The attribute will need to be either a Proxy (reference-one) or
             * PersistentCollection (reference-many) in order to prime anything.
             */ if ( ! is_object ( $ value ) ) { continue ; } if ( $ mapping -> isOne ( ) && $ value instanceof Proxy && ! $ value -> __isInitialized ( ) ) { $ identifier = $ this -> uow -> getDocumentIdentifier ( $ value ) ; $ className = $ identifier -> class -> getName ( ) ; $ this -> groupedIds [ $ className ] [ $ identifier -> getSerialized ( ) ] = $ identifier ; } elseif ( $ mapping -> isMany ( ) && $ value instanceof PersistentCollectionInterface ) { $ this -> addManyReferences ( $ value ) ; } } foreach ( $ this -> groupedIds as $ className => $ ids ) { $ class = $ this -> dm -> getClassMetadata ( $ className ) ; call_user_func ( $ primer , $ this -> dm , $ class , array_values ( $ ids ) , $ refresh , $ readOnly ) ; } }
Prime references within a mapped attribute of one or more documents.

If a $primer callable is provided, it should have the same signature as
the default primer defined in the constructor. If $primer is not
callable, the default primer will be used.

@param ClassMetadata      $class         Class metadata for the document
@param array|\Traversable $documents     Documents containing references to prime
@param string             $attributeName Attribute name containing references to prime
@param bool               $refresh
@param bool               $readOnly
@param callable           $primer        Optional primer callable
Prime references within a mapped attribute of one or more documents .