src/Sulu/Component/DocumentManager/Subscriber/Core/MappingSubscriber.php
private function persistReference(
        NodeInterface $node,
        DocumentAccessor $accessor,
        $fieldName,
        $locale,
        $fieldMapping
    ) {
        $referenceDocument = $accessor->get($fieldName);

        if (!$referenceDocument) {
            return;
        }

        if ($fieldMapping['multiple']) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Mapping references as multiple not currently supported (when mapping "%s")',
                    $fieldName
                )
            );
        }

        try {
            $referenceNode = $this->documentRegistry->getNodeForDocument($referenceDocument);
            $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale);
            $node->setProperty($phpcrName, $referenceNode);
        } catch (InvalidLocaleException $ex) {
            // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)
            return;
        }
    }
private function persistReference(
        NodeInterface $node,
        DocumentAccessor $accessor,
        $fieldName,
        $locale,
        $fieldMapping
    ) {
        $referenceDocument = $accessor->get($fieldName);

        if (!$referenceDocument) {
            return;
        }

        if ($fieldMapping['multiple']) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Mapping references as multiple not currently supported (when mapping "%s")',
                    $fieldName
                )
            );
        }

        try {
            $referenceNode = $this->documentRegistry->getNodeForDocument($referenceDocument);
            $phpcrName = $this->encoder->encode($fieldMapping['encoding'], $fieldMapping['property'], $locale);
            $node->setProperty($phpcrName, $referenceNode);
        } catch (InvalidLocaleException $ex) {
            // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding)
            return;
        }
    }
private function persistReference ( NodeInterface $ node , DocumentAccessor $ accessor , $ fieldName , $ locale , $ fieldMapping ) { $ referenceDocument = $ accessor -> get ( $ fieldName ) ; if ( ! $ referenceDocument ) { return ; } if ( $ fieldMapping [ 'multiple' ] ) { throw new \ InvalidArgumentException ( sprintf ( 'Mapping references as multiple not currently supported (when mapping "%s")' , $ fieldName ) ) ; } try { $ referenceNode = $ this -> documentRegistry -> getNodeForDocument ( $ referenceDocument ) ; $ phpcrName = $ this -> encoder -> encode ( $ fieldMapping [ 'encoding' ] , $ fieldMapping [ 'property' ] , $ locale ) ; $ node -> setProperty ( $ phpcrName , $ referenceNode ) ; } catch ( InvalidLocaleException $ ex ) { // arguments invalid, no valid propertyname could be generated (e.g. no locale given for localized encoding) return ; } }
Persist a reference field type.

@param NodeInterface $node
@param DocumentAccessor $accessor
@param mixed $fieldName
@param mixed $locale
@param mixed $fieldMapping
Persist a reference field type .