Skip to content

Commit e8735e6

Browse files
author
Thomas Courthial
committed
[CHILD REMOVAL] Adding a parameter "removeChild" to delete the
child entity of a relation when unsetting this child entity in the parent entity (#childRemoval)
1 parent a2bdbfd commit e8735e6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Services/DataMapper/XmlMapper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private function xmlElementToEntity(array $mapping, \SimpleXMLElement $xmlElemen
101101
}
102102

103103
// If xmlKey not found in XMl Data, there's no object to create. So we return null
104-
if (!isset($description['key']['xmlKey'])) {
104+
if (!isset($keys[0])) {
105105
return null;
106106
} elseif(is_array($description['key']['xmlKey'])) {
107107
$oldObject = $em->getRepository($description['repository'])->$findFunction($keys);
@@ -141,7 +141,10 @@ private function xmlElementToEntity(array $mapping, \SimpleXMLElement $xmlElemen
141141
if ($oldElements != null) {
142142
foreach ($oldElements as $oldElement) {
143143
$$objectName->$typeDescription['clear']['removeFunction']($oldElement);
144-
//$em->remove($oldElement);
144+
if(isset($typeDescription['clear']['removeChild']) && $typeDescription['clear']['removeChild'])
145+
{
146+
$em->remove($oldElement);
147+
}
145148
}
146149
}
147150
}

0 commit comments

Comments
 (0)