diff --git a/Repository/PhpcrOdmRepository.php b/Repository/PhpcrOdmRepository.php index 3b41292..c99fbd1 100644 --- a/Repository/PhpcrOdmRepository.php +++ b/Repository/PhpcrOdmRepository.php @@ -99,7 +99,9 @@ public function reorderNode($sourcePath, $position) $nodeNames = $parent->getNodeNames(); $parentDocument = $this->getManager()->find(null, $parent->getPath()); - if (isset($nodeNames[$position + 1])) { + if ($position == 0) { + $this->getManager()->reorder($parentDocument, $node->getName(), $nodeNames[$position], true); + } elseif (isset($nodeNames[$position + 1])) { $this->getManager()->reorder($parentDocument, $node->getName(), $nodeNames[$position + 1], true); } else { $lastName = end($nodeNames); diff --git a/Repository/PhpcrRepository.php b/Repository/PhpcrRepository.php index 8f7c484..a29caed 100644 --- a/Repository/PhpcrRepository.php +++ b/Repository/PhpcrRepository.php @@ -140,7 +140,9 @@ public function reorderNode($sourcePath, $position) $parent = $node->getParent(); $nodeNames = $parent->getNodeNames(); - if (isset($nodeNames[$position + 1])) { + if ($position == 0) { + $parent->orderBefore($node->getName(), $nodeNames[$position]); + } elseif (isset($nodeNames[$position + 1])) { $parent->orderBefore($node->getName(), $nodeNames[$position + 1]); } else { $lastName = $nodeNames[count($nodeNames) - 1];