/** * Move current node and its children to location $destLeft and updates rest of tree * * @param int $destLeft Destination left value * @param int $levelDelta Delta to add to the levels * @param PropelPDO $con Connection to use. */ protected function moveSubtreeTo($destLeft, $levelDelta, PropelPDO $con = null) { $left = $this->getLeftValue(); $right = $this->getRightValue(); $scope = $this->getScopeValue(); $treeSize = $right - $left + 1; if ($con === null) { $con = Propel::getConnection(EspecialidadPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { // make room next to the target for the subtree EspecialidadPeer::shiftRLValues($treeSize, $destLeft, null, $scope, $con); if ($left >= $destLeft) { // src was shifted too? $left += $treeSize; $right += $treeSize; } if ($levelDelta) { // update the levels of the subtree EspecialidadPeer::shiftLevel($levelDelta, $left, $right, $scope, $con); } // move the subtree to the target EspecialidadPeer::shiftRLValues($destLeft - $left, $left, $right, $scope, $con); // remove the empty room at the previous location of the subtree EspecialidadPeer::shiftRLValues(-$treeSize, $right + 1, null, $scope, $con); // update all loaded nodes EspecialidadPeer::updateLoadedNodes(null, $con); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } }