1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Better generation of exported xml (valid with xsd)

This commit is contained in:
Asmir Mustafic 2011-11-18 10:57:27 +01:00
parent 43b1e79ec4
commit 82a1626e82

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,7 +217,11 @@ class XmlExporter extends AbstractExporter
if (isset($associationMapping['inversedBy'])) {
$associationMappingXml->addAttribute('inversed-by', $associationMapping['inversedBy']);
}
if (isset($associationMapping['orphanRemoval'])) {
if (isset($associationMapping['indexBy'])) {
$associationMappingXml->addAttribute('index-by', $associationMapping['indexBy']);
}
if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']!==false) {
// false is the xml default
$associationMappingXml->addAttribute('orphan-removal', $associationMapping['orphanRemoval']);
}
if (isset($associationMapping['joinTable']) && $associationMapping['joinTable']) {
@ -287,7 +304,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) {