public function objectToDocument(IndexMetadata $metadata, $object)
    {
        $indexNameField = $metadata->getIndexName();
        $idField = $metadata->getIdField();
        $urlField = $metadata->getUrlField();
        $titleField = $metadata->getTitleField();
        $descriptionField = $metadata->getDescriptionField();
        $imageUrlField = $metadata->getImageUrlField();
        $localeField = $metadata->getLocaleField();
        $fieldMapping = $metadata->getFieldMapping();

        $document = $this->factory->createDocument();
        $document->setIndex($this->fieldEvaluator->getValue($object, $indexNameField));
        $document->setId($this->fieldEvaluator->getValue($object, $idField));
        $document->setClass($metadata->getName());

        if ($urlField) {
            $url = $this->fieldEvaluator->getValue($object, $urlField);
            if ($url) {
                $document->setUrl($url);
            }
        }

        if ($titleField) {
            $title = $this->fieldEvaluator->getValue($object, $titleField);
            if ($title) {
                $document->setTitle($title);
            }
        }

        if ($descriptionField) {
            $description = $this->fieldEvaluator->getValue($object, $descriptionField);
            if ($description) {
                $document->setDescription($description);
            }
        }

        if ($imageUrlField) {
            $imageUrl = $this->fieldEvaluator->getValue($object, $imageUrlField);
            $document->setImageUrl($imageUrl);
        }

        if ($localeField) {
            $locale = $this->fieldEvaluator->getValue($object, $localeField);
            $document->setLocale($locale);
        }

        $this->populateDocument($document, $object, $fieldMapping);

        return $document;
    }
public function objectToDocument(IndexMetadata $metadata, $object)
    {
        $indexNameField = $metadata->getIndexName();
        $idField = $metadata->getIdField();
        $urlField = $metadata->getUrlField();
        $titleField = $metadata->getTitleField();
        $descriptionField = $metadata->getDescriptionField();
        $imageUrlField = $metadata->getImageUrlField();
        $localeField = $metadata->getLocaleField();
        $fieldMapping = $metadata->getFieldMapping();

        $document = $this->factory->createDocument();
        $document->setIndex($this->fieldEvaluator->getValue($object, $indexNameField));
        $document->setId($this->fieldEvaluator->getValue($object, $idField));
        $document->setClass($metadata->getName());

        if ($urlField) {
            $url = $this->fieldEvaluator->getValue($object, $urlField);
            if ($url) {
                $document->setUrl($url);
            }
        }

        if ($titleField) {
            $title = $this->fieldEvaluator->getValue($object, $titleField);
            if ($title) {
                $document->setTitle($title);
            }
        }

        if ($descriptionField) {
            $description = $this->fieldEvaluator->getValue($object, $descriptionField);
            if ($description) {
                $document->setDescription($description);
            }
        }

        if ($imageUrlField) {
            $imageUrl = $this->fieldEvaluator->getValue($object, $imageUrlField);
            $document->setImageUrl($imageUrl);
        }

        if ($localeField) {
            $locale = $this->fieldEvaluator->getValue($object, $localeField);
            $document->setLocale($locale);
        }

        $this->populateDocument($document, $object, $fieldMapping);

        return $document;
    }
public function objectToDocument ( IndexMetadata $ metadata , $ object ) { $ indexNameField = $ metadata -> getIndexName ( ) ; $ idField = $ metadata -> getIdField ( ) ; $ urlField = $ metadata -> getUrlField ( ) ; $ titleField = $ metadata -> getTitleField ( ) ; $ descriptionField = $ metadata -> getDescriptionField ( ) ; $ imageUrlField = $ metadata -> getImageUrlField ( ) ; $ localeField = $ metadata -> getLocaleField ( ) ; $ fieldMapping = $ metadata -> getFieldMapping ( ) ; $ document = $ this -> factory -> createDocument ( ) ; $ document -> setIndex ( $ this -> fieldEvaluator -> getValue ( $ object , $ indexNameField ) ) ; $ document -> setId ( $ this -> fieldEvaluator -> getValue ( $ object , $ idField ) ) ; $ document -> setClass ( $ metadata -> getName ( ) ) ; if ( $ urlField ) { $ url = $ this -> fieldEvaluator -> getValue ( $ object , $ urlField ) ; if ( $ url ) { $ document -> setUrl ( $ url ) ; } } if ( $ titleField ) { $ title = $ this -> fieldEvaluator -> getValue ( $ object , $ titleField ) ; if ( $ title ) { $ document -> setTitle ( $ title ) ; } } if ( $ descriptionField ) { $ description = $ this -> fieldEvaluator -> getValue ( $ object , $ descriptionField ) ; if ( $ description ) { $ document -> setDescription ( $ description ) ; } } if ( $ imageUrlField ) { $ imageUrl = $ this -> fieldEvaluator -> getValue ( $ object , $ imageUrlField ) ; $ document -> setImageUrl ( $ imageUrl ) ; } if ( $ localeField ) { $ locale = $ this -> fieldEvaluator -> getValue ( $ object , $ localeField ) ; $ document -> setLocale ( $ locale ) ; } $ this -> populateDocument ( $ document , $ object , $ fieldMapping ) ; return $ document ; }
Map the given object to a new document using the
given metadata.

@param IndexMetadata $metadata
@param object $object

@return Document
Map the given object to a new document using the given metadata .