/** * inserts node as last child of given node * * @param NodeWrapper $node */ public function insertAsLastChildOf(NodeWrapper $node) { if ($node === $this) { throw new \InvalidArgumentException('Cannot insert node as a child of itself'); } $em = $this->getManager()->getEntityManager(); $newLeft = $node->getRightValue(); $newRight = $node->getRightValue() + 1; $newRoot = $this->hasManyRoots() ? $node->getRootValue() : null; // beginTransaction $em->getConnection()->beginTransaction(); try { $this->shiftRLRange($newLeft, 0, 2, $newRoot); $this->insertNode($newLeft, $newRight, $newRoot); $em->flush(); $em->getConnection()->commit(); } catch (\Exception $e) { // @codeCoverageIgnoreStart $em->close(); $em->getConnection()->rollback(); throw $e; // @codeCoverageIgnoreEnd } // endTransaction }