Commit f9b53c6b authored by Roman S. Borschel's avatar Roman S. Borschel

Fixed #DDC-580

Conflicts:

	lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
parent f619a15a
......@@ -66,6 +66,7 @@ class XmlDriver extends AbstractFileDriver
if (isset($xmlRoot['table'])) {
$table['name'] = (string)$xmlRoot['table'];
}
$metadata->setPrimaryTable($table);
/* not implemented specially anyway. use table = schema.table
......@@ -111,13 +112,13 @@ class XmlDriver extends AbstractFileDriver
} else {
$columns = $index['columns'];
}
$metadata->table['indexes'][$index['name']] = array(
'columns' => $columns
);
}
}
// Evaluate <unique-constraints..>
if (isset($xmlRoot->{'unique-constraints'})) {
foreach ($xmlRoot->{'unique-constraints'}->{'unique-constraint'} as $unique) {
......@@ -142,27 +143,27 @@ class XmlDriver extends AbstractFileDriver
'fieldName' => (string)$fieldMapping['name'],
'type' => (string)$fieldMapping['type']
);
if (isset($fieldMapping['column'])) {
$mapping['columnName'] = (string)$fieldMapping['column'];
}
if (isset($fieldMapping['length'])) {
$mapping['length'] = (int)$fieldMapping['length'];
}
if (isset($fieldMapping['precision'])) {
$mapping['precision'] = (int)$fieldMapping['precision'];
}
if (isset($fieldMapping['scale'])) {
$mapping['scale'] = (int)$fieldMapping['scale'];
}
if (isset($fieldMapping['unique'])) {
$mapping['unique'] = ((string)$fieldMapping['unique'] == "false") ? false : true;
}
if (isset($fieldMapping['options'])) {
$mapping['options'] = (array)$fieldMapping['options'];
}
......@@ -170,15 +171,15 @@ class XmlDriver extends AbstractFileDriver
if (isset($fieldMapping['nullable'])) {
$mapping['nullable'] = ((string)$fieldMapping['nullable'] == "false") ? false : true;
}
if (isset($fieldMapping['version']) && $fieldMapping['version']) {
$metadata->setVersionMapping($mapping);
}
if (isset($fieldMapping['column-definition'])) {
$mapping['columnDefinition'] = (string)$fieldMapping['column-definition'];
}
$metadata->mapField($mapping);
}
}
......@@ -190,11 +191,11 @@ class XmlDriver extends AbstractFileDriver
'fieldName' => (string)$idElement['name'],
'type' => (string)$idElement['type']
);
if (isset($idElement['column'])) {
$mapping['columnName'] = (string)$idElement['column'];
}
$metadata->mapField($mapping);
if (isset($idElement->generator)) {
......@@ -224,11 +225,11 @@ class XmlDriver extends AbstractFileDriver
'fieldName' => (string)$oneToOneElement['field'],
'targetEntity' => (string)$oneToOneElement['target-entity']
);
if (isset($oneToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$oneToOneElement['fetch']);
}
if (isset($oneToOneElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$oneToOneElement['mapped-by'];
} else {
......@@ -236,7 +237,7 @@ class XmlDriver extends AbstractFileDriver
$mapping['inversedBy'] = (string)$oneToOneElement['inversed-by'];
}
$joinColumns = array();
if (isset($oneToOneElement->{'join-column'})) {
$joinColumns[] = $this->_getJoinColumnMapping($oneToOneElement->{'join-column'});
} else if (isset($oneToOneElement->{'join-columns'})) {
......@@ -244,10 +245,10 @@ class XmlDriver extends AbstractFileDriver
$joinColumns[] = $this->_getJoinColumnMapping($joinColumnElement);
}
}
$mapping['joinColumns'] = $joinColumns;
}
if (isset($oneToOneElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($oneToOneElement->cascade);
}
......@@ -255,7 +256,7 @@ class XmlDriver extends AbstractFileDriver
if (isset($oneToOneElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$oneToOneElement->{'orphan-removal'};
}
$metadata->mapOneToOne($mapping);
}
}
......@@ -268,15 +269,15 @@ class XmlDriver extends AbstractFileDriver
'targetEntity' => (string)$oneToManyElement['target-entity'],
'mappedBy' => (string)$oneToManyElement['mapped-by']
);
if (isset($oneToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$oneToManyElement['fetch']);
}
if (isset($oneToManyElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($oneToManyElement->cascade);
}
if (isset($oneToManyElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$oneToManyElement->{'orphan-removal'};
}
......@@ -288,11 +289,11 @@ class XmlDriver extends AbstractFileDriver
}
$mapping['orderBy'] = $orderBy;
}
$metadata->mapOneToMany($mapping);
}
}
// Evaluate <many-to-one ...> mappings
if (isset($xmlRoot->{'many-to-one'})) {
foreach ($xmlRoot->{'many-to-one'} as $manyToOneElement) {
......@@ -300,7 +301,7 @@ class XmlDriver extends AbstractFileDriver
'fieldName' => (string)$manyToOneElement['field'],
'targetEntity' => (string)$manyToOneElement['target-entity']
);
if (isset($manyToOneElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToOneElement['fetch']);
}
......@@ -327,15 +328,15 @@ class XmlDriver extends AbstractFileDriver
if (isset($manyToOneElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($manyToOneElement->cascade);
}
if (isset($manyToOneElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$manyToOneElement->{'orphan-removal'};
}
$metadata->mapManyToOne($mapping);
}
}
// Evaluate <many-to-many ...> mappings
if (isset($xmlRoot->{'many-to-many'})) {
foreach ($xmlRoot->{'many-to-many'} as $manyToManyElement) {
......@@ -343,11 +344,11 @@ class XmlDriver extends AbstractFileDriver
'fieldName' => (string)$manyToManyElement['field'],
'targetEntity' => (string)$manyToManyElement['target-entity']
);
if (isset($manyToManyElement['fetch'])) {
$mapping['fetch'] = constant('Doctrine\ORM\Mapping\AssociationMapping::FETCH_' . (string)$manyToManyElement['fetch']);
}
if (isset($manyToManyElement['mapped-by'])) {
$mapping['mappedBy'] = (string)$manyToManyElement['mapped-by'];
} else if (isset($manyToManyElement->{'join-table'})) {
......@@ -363,22 +364,22 @@ class XmlDriver extends AbstractFileDriver
if (isset($joinTableElement['schema'])) {
$joinTable['schema'] = (string)$joinTableElement['schema'];
}
foreach ($joinTableElement->{'join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['joinColumns'][] = $this->_getJoinColumnMapping($joinColumnElement);
}
foreach ($joinTableElement->{'inverse-join-columns'}->{'join-column'} as $joinColumnElement) {
$joinTable['inverseJoinColumns'][] = $this->_getJoinColumnMapping($joinColumnElement);
}
$mapping['joinTable'] = $joinTable;
}
if (isset($manyToManyElement->cascade)) {
$mapping['cascade'] = $this->_getCascadeMappings($manyToManyElement->cascade);
}
if (isset($manyToManyElement->{'orphan-removal'})) {
$mapping['orphanRemoval'] = (bool)$manyToManyElement->{'orphan-removal'};
}
......@@ -390,7 +391,7 @@ class XmlDriver extends AbstractFileDriver
}
$mapping['orderBy'] = $orderBy;
}
$metadata->mapManyToMany($mapping);
}
}
......@@ -406,7 +407,7 @@ class XmlDriver extends AbstractFileDriver
/**
* Constructs a joinColumn mapping array based on the information
* found in the given SimpleXMLElement.
*
*
* @param $joinColumnElement The XML element.
* @return array The mapping array.
*/
......@@ -416,19 +417,19 @@ class XmlDriver extends AbstractFileDriver
'name' => (string)$joinColumnElement['name'],
'referencedColumnName' => (string)$joinColumnElement['referenced-column-name']
);
if (isset($joinColumnElement['unique'])) {
$joinColumn['unique'] = ((string)$joinColumnElement['unique'] == "false") ? false : true;
}
if (isset($joinColumnElement['nullable'])) {
$joinColumn['nullable'] = ((string)$joinColumnElement['nullable'] == "false") ? false : true;
}
if (isset($joinColumnElement['on-delete'])) {
$joinColumn['onDelete'] = (string)$joinColumnElement['on-delete'];
}
if (isset($joinColumnElement['on-update'])) {
$joinColumn['onUpdate'] = (string)$joinColumnElement['on-update'];
}
......@@ -436,13 +437,13 @@ class XmlDriver extends AbstractFileDriver
if (isset($joinColumnElement['column-definition'])) {
$joinColumn['columnDefinition'] = (string)$joinColumnElement['column-definition'];
}
return $joinColumn;
}
/**
* Gathers a list of cascade options found in the given cascade element.
*
*
* @param $cascadeElement The cascade element.
* @return array The list of cascade options.
*/
......@@ -459,7 +460,7 @@ class XmlDriver extends AbstractFileDriver
}
return $cascades;
}
/**
* {@inheritdoc}
*/
......@@ -474,7 +475,7 @@ class XmlDriver extends AbstractFileDriver
$result[$entityName] = $entityElement;
}
} else if (isset($xmlElement->{'mapped-superclass'})) {
foreach ($xmlElement->{'mapped-superclass'} as $mapperSuperClass) {
foreach ($xmlElement->{'mapped-superclass'} as $mappedSuperClass) {
$className = (string)$mappedSuperClass['name'];
$result[$className] = $mappedSuperClass;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment