Skip to content

Commit

Permalink
#1204 - refactored sequence-generator metadata exporting into own pri…
Browse files Browse the repository at this point in the history
…vate method for simplicity
  • Loading branch information
Ocramius committed Dec 4, 2014
1 parent aa14545 commit ce308dc
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,8 @@ public function exportClassMetadata(ClassMetadataInfo $metadata)
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);
}
}
}
Expand Down Expand Up @@ -417,6 +413,29 @@ private function exportTableOptions(\SimpleXMLElement $parentXml, array $options
}
}

/**
* 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
*
Expand Down

0 comments on commit ce308dc

Please sign in to comment.