Example #1
0
 /**
  * Inserts the current node as last child of given $parent node
  * The modifications in the current object and the tree
  * are not persisted until the current object is saved.
  *
  * @param      Page $parent	Propel object for parent node
  *
  * @return     Page The current Propel object
  */
 public function insertAsLastChildOf($parent)
 {
     if ($this->isInTree()) {
         throw new PropelException('A Page object must not already be in the tree to be inserted. Use the moveToLastChildOf() instead.');
     }
     $left = $parent->getRightValue();
     // Update node properties
     $this->setLeftValue($left);
     $this->setRightValue($left + 1);
     $this->setLevel($parent->getLevel() + 1);
     // update the children collection of the parent
     $parent->addNestedSetChild($this);
     // Keep the tree modification query for the save() transaction
     $this->nestedSetQueries[] = array('callable' => array('PagePeer', 'makeRoomForLeaf'), 'arguments' => array($left, $this->isNew() ? null : $this));
     return $this;
 }