Skip to content

Commit

Permalink
fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
safrazik committed Jun 5, 2014
1 parent d1d96cc commit 93ce7dc
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions src/Adrotec/BreezeJs/Doctrine/ORM/SaveContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,21 @@ public function saveChangesTemp(SaveBundle $saveBundle) {
$associations = array();

if ($entityAspect->entityState == 'Modified' || $entityAspect->entityState == 'Added') {
foreach ($entityArr as $propertyName => $propertyValue) {
$propertyType = $this->getPropertyType($meta, $propertyName);
if ($propertyType === self::PROPERTY_TYPE_NONE) {
continue;
}
$fieldMapping = false;
if (isset($meta->fieldMappings[$propertyName])) {
$fieldMapping = $meta->fieldMappings[$propertyName];
}
$setter = false; //('set' . ucfirst($propertyName));
$propertyValue = $entityArr->$propertyName;
try {
$propertyValue = $this->convertToDoctrineValue($propertyValue,
$fieldMapping ? $fieldMapping['type'] : 'string');
} catch (\Exception $e) {
throw $e;
$processedProperties = array();
foreach ($meta->fieldMappings as $propertyName => $fieldMapping) {
if (property_exists($entityArr, $propertyName)) {
$setter = false; //('set' . ucfirst($propertyName));
$propertyValue = $entityArr->$propertyName;
try {
$propertyValue = $this->convertToDoctrineValue($propertyValue,
$fieldMapping ? $fieldMapping['type'] : 'string');
} catch (\Exception $e) {
throw $e;
}
$this->setObjectValue($entity, $propertyName, $propertyValue, $setter);
$processedProperties[] = $propertyName;
}
$this->setObjectValue($entity, $propertyName, $propertyValue, $setter);
}
// foreach ($meta->fieldMappings as $propertyName => $fieldMapping) {
// if (property_exists($entityArr, $propertyName)) {
//
// }
// }
foreach ($meta->associationMappings as $associationName => $associationFieldMapping) {
// $associationFieldMapping = $meta->associationMappings[$propertyName];
$fkFieldName = $this->getForeignKeyFieldName($associationFieldMapping);
Expand All @@ -232,8 +223,22 @@ public function saveChangesTemp(SaveBundle $saveBundle) {
'referencedFieldValue' => $entityArr->$fkFieldName,
'setter' => $associationSetter,
);
$processedProperties[] = $fkFieldName;
}
}
foreach ($entityArr as $propertyName => $propertyValue) {
if(in_array($propertyName, $processedProperties)){
continue;
}
$propertyType = $this->getPropertyType($meta, $propertyName);
if ($propertyType === self::PROPERTY_TYPE_NONE) {
continue;
}
$setter = false; //('set' . ucfirst($propertyName));
$propertyValue = $entityArr->$propertyName;
$this->setObjectValue($entity, $propertyName, $propertyValue, $setter);
}

} else if ($entityAspect->entityState == 'Deleted') {

} else {
Expand Down

0 comments on commit 93ce7dc

Please sign in to comment.