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