1
0
mirror of synced 2024-12-14 07:06:04 +03:00

Merge pull request #196 from goetas/manyidx

Added some improvments for generated XML
This commit is contained in:
Benjamin Eberlei 2012-01-28 13:11:22 -08:00
commit 359a9c015b

View File

@ -95,7 +95,10 @@ class XmlExporter extends AbstractExporter
}
}
$root->addChild('change-tracking-policy', $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy));
$trackingPolicy = $this->_getChangeTrackingPolicyString($metadata->changeTrackingPolicy);
if ( $trackingPolicy != 'DEFERRED_IMPLICIT') {
$root->addChild('change-tracking-policy', $trackingPolicy);
}
if (isset($metadata->table['indexes'])) {
$indexesXml = $root->addChild('indexes');
@ -183,7 +186,17 @@ class XmlExporter extends AbstractExporter
}
}
}
$orderMap = array(
ClassMetadataInfo::ONE_TO_ONE,
ClassMetadataInfo::ONE_TO_MANY,
ClassMetadataInfo::MANY_TO_ONE,
ClassMetadataInfo::MANY_TO_MANY,
);
uasort($metadata->associationMappings, function($m1, $m2)use(&$orderMap){
$a1 = array_search($m1['type'],$orderMap);
$a2 = array_search($m2['type'],$orderMap);
return strcmp($a1, $a2);
});
foreach ($metadata->associationMappings as $name => $associationMapping) {
if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_ONE) {
$associationMappingXml = $root->addChild('one-to-one');
@ -204,8 +217,11 @@ class XmlExporter extends AbstractExporter
if (isset($associationMapping['inversedBy'])) {
$associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']);
}
if (isset($associationMapping['orphanRemoval'])) {
$associationMappingXml->addAttribute('orphan-removal', $associationMapping['orphanRemoval']);
if (isset($associationMapping['indexBy'])) {
$associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']);
}
if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']!==false) {
$associationMappingXml->addAttribute('orphan-removal', 'true');
}
if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) {
$joinTableXml = $associationMappingXml->addChild('join-table');
@ -290,7 +306,7 @@ class XmlExporter extends AbstractExporter
}
}
if (isset($metadata->lifecycleCallbacks)) {
if (isset($metadata->lifecycleCallbacks) && count($metadata->lifecycleCallbacks)>0) {
$lifecycleCallbacksXml = $root->addChild('lifecycle-callbacks');
foreach ($metadata->lifecycleCallbacks as $name => $methods) {
foreach ($methods as $method) {
@ -317,4 +333,4 @@ class XmlExporter extends AbstractExporter
$result = $dom->saveXML();
return $result;
}
}
}