diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php index 01309475b..8ec4d5cd5 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/XmlExporter.php @@ -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) {