コード例 #1
0
ファイル: node.php プロジェクト: nikosdion/Akeeba-Example
	/**
	 * Add child to this node
	 *
	 * If the child already has a parent, the link is unset
	 *
	 * @param   JNode  $child  The child to be added
	 *
	 * @return  void
	 *
	 * @since   11.1
	 */
	function addChild(&$child)
	{
		if ($child instanceof Jnode)
		{
			$child->setParent($this);
		}
	}
コード例 #2
0
 /**
  * JDoublyLinkedList::createNode()
  *
  * @param mixed $value
  * @return
  */
 public function createNode($value)
 {
     if (!isset($value)) {
         throw new Exception('A value is required to create a node');
     }
     $node = new JNode($value);
     $uid = $node->getUid();
     $this->_list[$uid] = $node;
     return $uid;
 }
コード例 #3
0
ファイル: JNodeTest.php プロジェクト: raquelsa/Joomla
 /**
  * Tests getting the children of a node.
  *
  * @group	JNode
  * @covers	JNode::getChildren
  * @return void
  */
 public function testGetChildren()
 {
     $this->assertEquals(array(), $this->object->getChildren(), 'New node should have null children');
     $this->assertAttributeEquals(array(), '_children', $this->object);
     $newChild = new JNode();
     $this->object->addChild($newChild);
     $this->assertEquals(array(spl_object_hash($newChild) => $newChild), $this->object->getChildren(), 'Node should have the created child');
     $this->assertAttributeEquals(array(spl_object_hash($newChild) => $newChild), '_children', $this->object);
 }
コード例 #4
0
ファイル: tree.php プロジェクト: jwadhwani/tree-php
 /**
  * JTree::createNode()
  *
  * Create a node, store in hash table
  * return the reference uid
  * @param mixed $value
  * @param string $uid
  * @return string $uid
  */
 public function createNode($value, $uid = null, $parentUid = null)
 {
     if (!isset($value)) {
         throw new Exception('A value is required to create a node');
     }
     //check if this node is already ready
     //in which case it must up for modification
     if (isset($this->_list[$uid])) {
         $this->modifyNode($value, $uid, $parentUid);
     } else {
         //base node
         $node = new JNode($value, $uid, $parentUid);
         $uid = $node->getUid();
         $this->_list[$uid] = $node;
     }
     //now to check if the parent node is ready
     //if not prepare one now.
     if (isset($parentUid) && !isset($this->_list[$parentUid])) {
         $parentNode = new JNode(null, $parentUid);
         $parentUid = $parentNode->getUid();
         $this->_list[$parentUid] = $parentNode;
     }
     //this node now becomes the child of
     //the parent node.
     if (isset($parentUid) && isset($this->_list[$parentUid])) {
         $this->addChild($parentUid, $uid);
     }
     return $uid;
 }
コード例 #5
0
ファイル: node.php プロジェクト: nprasath002/joomla-platform
 /**
  * Add child to this node
  *
  * If the child already has a parent, the link is unset
  *
  * @param   JNode  &$child  The child to be added
  *
  * @return  void
  *
  * @since   11.1
  */
 public function addChild(JNode &$child)
 {
     JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');
     $child->setParent($this);
 }