src/Sulu/Component/CustomUrl/Manager/CustomUrlManager.php
private function bind(CustomUrlDocument $document, $data)
    {
        $document->setTitle($data['title']);
        unset($data['title']);

        $metadata = $this->metadataFactory->getMetadataForAlias('custom_url');

        $accessor = PropertyAccess::createPropertyAccessor();

        foreach ($metadata->getFieldMappings() as $fieldName => $mapping) {
            if (!array_key_exists($fieldName, $data)) {
                continue;
            }

            $value = $data[$fieldName];
            if (array_key_exists('type', $mapping) && 'reference' === $mapping['type']) {
                $value = $this->documentManager->find($value, LOCALE, ['load_ghost_content' => true]);
            }

            $accessor->setValue($document, $fieldName, $value);
        }
    }
private function bind(CustomUrlDocument $document, $data)
    {
        $document->setTitle($data['title']);
        unset($data['title']);

        $metadata = $this->metadataFactory->getMetadataForAlias('custom_url');

        $accessor = PropertyAccess::createPropertyAccessor();

        foreach ($metadata->getFieldMappings() as $fieldName => $mapping) {
            if (!array_key_exists($fieldName, $data)) {
                continue;
            }

            $value = $data[$fieldName];
            if (array_key_exists('type', $mapping) && 'reference' === $mapping['type']) {
                $value = $this->documentManager->find($value, LOCALE, ['load_ghost_content' => true]);
            }

            $accessor->setValue($document, $fieldName, $value);
        }
    }
private function bind ( CustomUrlDocument $ document , $ data ) { $ document -> setTitle ( $ data [ 'title' ] ) ; unset ( $ data [ 'title' ] ) ; $ metadata = $ this -> metadataFactory -> getMetadataForAlias ( 'custom_url' ) ; $ accessor = PropertyAccess :: createPropertyAccessor ( ) ; foreach ( $ metadata -> getFieldMappings ( ) as $ fieldName => $ mapping ) { if ( ! array_key_exists ( $ fieldName , $ data ) ) { continue ; } $ value = $ data [ $ fieldName ] ; if ( array_key_exists ( 'type' , $ mapping ) && 'reference' === $ mapping [ 'type' ] ) { $ value = $ this -> documentManager -> find ( $ value , LOCALE , [ 'load_ghost_content' => true ] ) ; } $ accessor -> setValue ( $ document , $ fieldName , $ value ) ; } }
Bind data array to given document.

TODO this logic have to be extracted in a proper way.

@param CustomUrlDocument $document
@param array $data
Bind data array to given document .