瀏覽代碼

[tree] fixed back persistAs method for siblings which was broken by PR #208

gedi 13 年之前
父節點
當前提交
67045fc4a8
共有 1 個文件被更改,包括 4 次插入5 次删除
  1. 4 5
      lib/Gedmo/Tree/Entity/Repository/NestedTreeRepository.php

+ 4 - 5
lib/Gedmo/Tree/Entity/Repository/NestedTreeRepository.php

@@ -93,17 +93,16 @@ class NestedTreeRepository extends AbstractTreeRepository
                 if (!isset($args[1])) {
                 if (!isset($args[1])) {
                     throw new \Gedmo\Exception\InvalidArgumentException('If "Of" is specified you must provide parent or sibling as the second argument');
                     throw new \Gedmo\Exception\InvalidArgumentException('If "Of" is specified you must provide parent or sibling as the second argument');
                 }
                 }
-                $parent = $args[1];
-    			$parent = substr($method,-7) == 'ChildOf' ? $parent : $parent->getParent();
-                
-                $wrapped->setPropertyValue($config['parent'], $parent);
+                $parentOrSibling = $args[1];
+                $wrapped->setPropertyValue($config['parent'], $parentOrSibling);
                 $position = substr($position, 0, -2);
                 $position = substr($position, 0, -2);
             }
             }
             $wrapped->setPropertyValue($config['left'], 0); // simulate changeset
             $wrapped->setPropertyValue($config['left'], 0); // simulate changeset
             $oid = spl_object_hash($node);
             $oid = spl_object_hash($node);
             $this->listener
             $this->listener
                 ->getStrategy($this->_em, $meta->name)
                 ->getStrategy($this->_em, $meta->name)
-                ->setNodePosition($oid, $position);
+                ->setNodePosition($oid, $position)
+            ;
 
 
             $this->_em->persist($node);
             $this->_em->persist($node);
             return $this;
             return $this;