/** * Update the tree to allow insertion of a leaf at the specified position * * @param int $left left column value * @param mixed $prune Object to prune from the shift * @param ConnectionInterface $con Connection to use. */ public static function makeRoomForLeaf($left, $prune = null, ConnectionInterface $con = null) { // Update database nodes ChildCategoryQuery::shiftRLValues(2, $left, null, $con); // Update all loaded nodes ChildCategoryQuery::updateLoadedNodes($prune, $con); }
/** * Deletes all descendants for the given node * Instance pooling is wiped out by this command, * so existing ChildCategory instances are probably invalid (except for the current one) * * @param ConnectionInterface $con Connection to use. * * @return int number of deleted nodes */ public function deleteDescendants(ConnectionInterface $con = null) { if ($this->isLeaf()) { // save one query return; } if (null === $con) { $con = Propel::getServiceContainer()->getReadConnection(CategoryTableMap::DATABASE_NAME); } $left = $this->getLeftValue(); $right = $this->getRightValue(); return $con->transaction(function () use($con, $left, $right) { // delete descendant nodes (will empty the instance pool) $ret = ChildCategoryQuery::create()->descendantsOf($this)->delete($con); // fill up the room that was used by descendants ChildCategoryQuery::shiftRLValues($left - $right + 1, $right, null, $con); // fix the right value for the current node, which is now a leaf $this->setRightValue($left + 1); return $ret; }); }