map test
[m6w6/pq-gateway] / lib / pq / Mapper / Property / All.php
index 49fb0a622b4310a9ed410ee316362b62aeb6658c..6eb49457645c246efb91c41d63b4a2e170e52b46 100644 (file)
@@ -46,15 +46,16 @@ class All implements RefPropertyInterface
        function write($object, Row $rowToUpdate) {
                $property = $this->findRefProperty($object);
                $map = $this->mapper->mapOf($this->refClass);
-               $refs = $this->extract($object);
-               foreach ($refs as $ref) {
-                       $property->assign($ref, $object);
-               }
-               return function() use($map, $refs) {
+               if (($refs = $this->extract($object))) {
                        foreach ($refs as $ref) {
-                               $map->unmap($ref);
+                               $property->assign($ref, $object);
                        }
-               };
+                       return function() use($map, $refs) {
+                               foreach ($refs as $ref) {
+                                       $map->unmap($ref);
+                               }
+                       };
+               }
        }
 
        /**