diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php index 29bb57bac..1d539c9f2 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -171,12 +171,8 @@ class XmlExporter extends AbstractExporter if ($idGeneratorType = $this->_getIdGeneratorTypeString($metadata->generatorType)) { $generatorXml = $idXml->addChild('generator'); $generatorXml->addAttribute('strategy', $idGeneratorType); - if($metadata->generatorType === ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE && $metadata->sequenceGeneratorDefinition) { - $sequenceGeneratorXml = $idXml->addChild('sequence-generator'); - $sequenceGeneratorXml->addAttribute('sequence-name', $metadata->sequenceGeneratorDefinition['sequenceName']); - $sequenceGeneratorXml->addAttribute('allocation-size', $metadata->sequenceGeneratorDefinition['allocationSize']); - $sequenceGeneratorXml->addAttribute('initial-value', $metadata->sequenceGeneratorDefinition['initialValue']); - } + + $this->exportSequenceInformation($idXml, $metadata); } } } @@ -417,6 +413,29 @@ class XmlExporter extends AbstractExporter } } + /** + * Export sequence information (if available/configured) into the current identifier XML node + * + * @param \SimpleXMLElement $identifierXmlNode + * @param ClassMetadataInfo $metadata + * + * @return void + */ + private function exportSequenceInformation(\SimpleXMLElement $identifierXmlNode, ClassMetadataInfo $metadata) + { + $sequenceDefinition = $metadata->sequenceGeneratorDefinition; + + if (! ($metadata->generatorType === ClassMetadataInfo::GENERATOR_TYPE_SEQUENCE && $sequenceDefinition)) { + return; + } + + $sequenceGeneratorXml = $identifierXmlNode->addChild('sequence-generator'); + + $sequenceGeneratorXml->addAttribute('sequence-name', $sequenceDefinition['sequenceName']); + $sequenceGeneratorXml->addAttribute('allocation-size', $sequenceDefinition['allocationSize']); + $sequenceGeneratorXml->addAttribute('initial-value', $sequenceDefinition['initialValue']); + } + /** * @param \SimpleXMLElement $simpleXml *