Neos.ContentRepository/Classes/Domain/Service/ImportExport/NodeExportService.php
protected function writeConvertedElement(array &$data, $propertyName, $elementName = null, $declaredPropertyType = null)
    {
        if (array_key_exists($propertyName, $data) && $data[$propertyName] !== null) {
            $propertyValue = $data[$propertyName];
            $this->xmlWriter->startElement($elementName ?: $propertyName);

            if (!empty($propertyValue)) {
                switch ($declaredPropertyType) {
                    case null:
                    case 'reference':
                    case 'references':
                        break;
                    default:
                        $propertyValue = $this->propertyMapper->convert($propertyValue, $declaredPropertyType);
                        break;
                }
            }

            $this->xmlWriter->writeAttribute('__type', gettype($propertyValue));
            try {
                if (is_object($propertyValue) && !$propertyValue instanceof \DateTimeInterface) {
                    $objectIdentifier = $this->persistenceManager->getIdentifierByObject($propertyValue);
                    if ($objectIdentifier !== null) {
                        $this->xmlWriter->writeAttribute('__identifier', $objectIdentifier);
                    }
                    if ($propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
                        $className = get_parent_class($propertyValue);
                    } else {
                        $className = get_class($propertyValue);
                    }
                    $this->xmlWriter->writeAttribute('__classname', $className);
                    $this->xmlWriter->writeAttribute('__encoding', 'json');

                    $converted = json_encode($this->propertyMapper->convert($propertyValue, 'array', $this->propertyMappingConfiguration));
                    $this->xmlWriter->text($converted);
                } elseif (is_array($propertyValue)) {
                    foreach ($propertyValue as $key => $element) {
                        $this->writeConvertedElement($propertyValue, $key, 'entry' . $key);
                    }
                } else {
                    if ($propertyValue instanceof \DateTimeInterface) {
                        $this->xmlWriter->writeAttribute('__classname', 'DateTime');
                    }
                    $this->xmlWriter->text($this->propertyMapper->convert($propertyValue, 'string', $this->propertyMappingConfiguration));
                }
            } catch (\Exception $exception) {
                $this->xmlWriter->writeComment(sprintf('Could not convert property "%s" to string.', $propertyName));
                $this->xmlWriter->writeComment($exception->getMessage());
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->exceptionsDuringExport[] = $exception;
            }

            $this->xmlWriter->endElement();
        }
    }
protected function writeConvertedElement(array &$data, $propertyName, $elementName = null, $declaredPropertyType = null)
    {
        if (array_key_exists($propertyName, $data) && $data[$propertyName] !== null) {
            $propertyValue = $data[$propertyName];
            $this->xmlWriter->startElement($elementName ?: $propertyName);

            if (!empty($propertyValue)) {
                switch ($declaredPropertyType) {
                    case null:
                    case 'reference':
                    case 'references':
                        break;
                    default:
                        $propertyValue = $this->propertyMapper->convert($propertyValue, $declaredPropertyType);
                        break;
                }
            }

            $this->xmlWriter->writeAttribute('__type', gettype($propertyValue));
            try {
                if (is_object($propertyValue) && !$propertyValue instanceof \DateTimeInterface) {
                    $objectIdentifier = $this->persistenceManager->getIdentifierByObject($propertyValue);
                    if ($objectIdentifier !== null) {
                        $this->xmlWriter->writeAttribute('__identifier', $objectIdentifier);
                    }
                    if ($propertyValue instanceof \Doctrine\ORM\Proxy\Proxy) {
                        $className = get_parent_class($propertyValue);
                    } else {
                        $className = get_class($propertyValue);
                    }
                    $this->xmlWriter->writeAttribute('__classname', $className);
                    $this->xmlWriter->writeAttribute('__encoding', 'json');

                    $converted = json_encode($this->propertyMapper->convert($propertyValue, 'array', $this->propertyMappingConfiguration));
                    $this->xmlWriter->text($converted);
                } elseif (is_array($propertyValue)) {
                    foreach ($propertyValue as $key => $element) {
                        $this->writeConvertedElement($propertyValue, $key, 'entry' . $key);
                    }
                } else {
                    if ($propertyValue instanceof \DateTimeInterface) {
                        $this->xmlWriter->writeAttribute('__classname', 'DateTime');
                    }
                    $this->xmlWriter->text($this->propertyMapper->convert($propertyValue, 'string', $this->propertyMappingConfiguration));
                }
            } catch (\Exception $exception) {
                $this->xmlWriter->writeComment(sprintf('Could not convert property "%s" to string.', $propertyName));
                $this->xmlWriter->writeComment($exception->getMessage());
                $logMessage = $this->throwableStorage->logThrowable($exception);
                $this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
                $this->exceptionsDuringExport[] = $exception;
            }

            $this->xmlWriter->endElement();
        }
    }
protected function writeConvertedElement ( array & $ data , $ propertyName , $ elementName = null , $ declaredPropertyType = null ) { if ( array_key_exists ( $ propertyName , $ data ) && $ data [ $ propertyName ] !== null ) { $ propertyValue = $ data [ $ propertyName ] ; $ this -> xmlWriter -> startElement ( $ elementName ? : $ propertyName ) ; if ( ! empty ( $ propertyValue ) ) { switch ( $ declaredPropertyType ) { case null : case 'reference' : case 'references' : break ; default : $ propertyValue = $ this -> propertyMapper -> convert ( $ propertyValue , $ declaredPropertyType ) ; break ; } } $ this -> xmlWriter -> writeAttribute ( '__type' , gettype ( $ propertyValue ) ) ; try { if ( is_object ( $ propertyValue ) && ! $ propertyValue instanceof \ DateTimeInterface ) { $ objectIdentifier = $ this -> persistenceManager -> getIdentifierByObject ( $ propertyValue ) ; if ( $ objectIdentifier !== null ) { $ this -> xmlWriter -> writeAttribute ( '__identifier' , $ objectIdentifier ) ; } if ( $ propertyValue instanceof \ Doctrine \ ORM \ Proxy \ Proxy ) { $ className = get_parent_class ( $ propertyValue ) ; } else { $ className = get_class ( $ propertyValue ) ; } $ this -> xmlWriter -> writeAttribute ( '__classname' , $ className ) ; $ this -> xmlWriter -> writeAttribute ( '__encoding' , 'json' ) ; $ converted = json_encode ( $ this -> propertyMapper -> convert ( $ propertyValue , 'array' , $ this -> propertyMappingConfiguration ) ) ; $ this -> xmlWriter -> text ( $ converted ) ; } elseif ( is_array ( $ propertyValue ) ) { foreach ( $ propertyValue as $ key => $ element ) { $ this -> writeConvertedElement ( $ propertyValue , $ key , 'entry' . $ key ) ; } } else { if ( $ propertyValue instanceof \ DateTimeInterface ) { $ this -> xmlWriter -> writeAttribute ( '__classname' , 'DateTime' ) ; } $ this -> xmlWriter -> text ( $ this -> propertyMapper -> convert ( $ propertyValue , 'string' , $ this -> propertyMappingConfiguration ) ) ; } } catch ( \ Exception $ exception ) { $ this -> xmlWriter -> writeComment ( sprintf ( 'Could not convert property "%s" to string.' , $ propertyName ) ) ; $ this -> xmlWriter -> writeComment ( $ exception -> getMessage ( ) ) ; $ logMessage = $ this -> throwableStorage -> logThrowable ( $ exception ) ; $ this -> logger -> error ( $ logMessage , LogEnvironment :: fromMethodName ( __METHOD__ ) ) ; $ this -> exceptionsDuringExport [ ] = $ exception ; } $ this -> xmlWriter -> endElement ( ) ; } }
Writes out a single property into the XML structure.

@param array $data The data as an array, the given property name is looked up there
@param string $propertyName The name of the property
@param string $elementName an optional name to use, defaults to $propertyName
@return void
Writes out a single property into the XML structure .