瀏覽代碼

[Loggable] fixed yaml mapping for relations

Gábor Egyed 14 年之前
父節點
當前提交
3413b9faae
共有 1 個文件被更改,包括 29 次插入0 次删除
  1. 29 0
      lib/Gedmo/Loggable/Mapping/Driver/Yaml.php

+ 29 - 0
lib/Gedmo/Loggable/Mapping/Driver/Yaml.php

@@ -60,6 +60,7 @@ class Yaml extends File implements Driver
                 }
             }
         }
+
         if (isset($mapping['fields'])) {
             foreach ($mapping['fields'] as $field => $fieldMapping) {
                 if (isset($fieldMapping['gedmo'])) {
@@ -73,6 +74,34 @@ class Yaml extends File implements Driver
                 }
             }
         }
+
+        if (isset($mapping['manyToOne'])) {
+            foreach ($mapping['manyToOne'] as $field => $fieldMapping) {
+                if (isset($fieldMapping['gedmo'])) {
+                    if (in_array('versioned', $fieldMapping['gedmo'])) {
+                        if ($meta->isCollectionValuedAssociation($field)) {
+                            throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}");
+                        }
+                        // fields cannot be overrided and throws mapping exception
+                        $config['versioned'][] = $field;
+                    }
+                }
+            }
+        }
+
+        if (isset($mapping['oneToOne'])) {
+            foreach ($mapping['oneToOne'] as $field => $fieldMapping) {
+                if (isset($fieldMapping['gedmo'])) {
+                    if (in_array('versioned', $fieldMapping['gedmo'])) {
+                        if ($meta->isCollectionValuedAssociation($field)) {
+                            throw new InvalidMappingException("Cannot versioned [{$field}] as it is collection in object - {$meta->name}");
+                        }
+                        // fields cannot be overrided and throws mapping exception
+                        $config['versioned'][] = $field;
+                    }
+                }
+            }
+        }
     }
 
     /**