Tree: ezcTreeNode
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcTreeNode
|
ezcTreeNode represents a node in a tree. [
source]
Implemented Interfaces
The methods that operate on nodes (fetchChildren, fetchPath, ..., isSiblingOf) are all marshalled to calls on the tree (that is stored in the $tree private variable) itself.
Example:
1. <?php
2. // Creates a new node with ID 'O' and as data 'Oxygen'
3. $node = new ezcTreeNode( $this->tree, 'O', 'Oxygen' );
4.
5. // Adds a node as child element to another already create node in a tree
6. $parentNode->addChild( $node );
7. ?>
Properties
|
mixed |
read/write
|
$data
The data belonging to a node |
|
bool |
read/write
|
$dataFetched
Whether the data for this node has been fetched. Should *only* be modified by data store implementations. |
|
bool |
read/write
|
$dataStored
Whether the data for this node has been stored. Should *only* be modified by data store implementations. |
|
string |
read
|
$id
The ID that uniquely identifies a node |
|
ezcTree |
read
|
$tree
The tree object that this node belongs to |
Method Summary
Methods
__construct
ezcTreeNode __construct(
ezcTree
$tree, string
$nodeId, mixed
$data )
Constructs a new ezcTreeNode object with ID $nodeId on tree $tree.
If a third argument is specified it is used as data for the new node.
Parameters
| Name |
Type |
Description |
$tree |
ezcTree |
|
$nodeId |
string |
|
$data |
mixed |
|
accept
Implements the accept method for visiting.
Parameters
addChild
Adds the node $node as child of the current node to the tree.
Parameters
fetchChildren
Returns all the children of this node.
fetchParent
Returns the parent node of this node.
fetchPath
Returns all the nodes in the path from the root node to this node.
fetchSubtree
Alias for fetchSubtreeDepthFirst().
See also:
ezcTreeNode::fetchSubtreeDepthFirst().
fetchSubtreeBreadthFirst
fetchSubtreeDepthFirst
getChildCount
int getChildCount(
)
Returns the number of direct children of this node.
getChildCountRecursive
int getChildCountRecursive(
)
Returns the number of children of this node, recursively iterating over the children.
getPathLength
int getPathLength(
)
Returns the distance from the root node to this node.
hasChildNodes
bool hasChildNodes(
)
Returns whether this node has children.
isChildOf
Returns whether this node is a direct child of the $parentNode node.
Parameters
isDescendantOf
Returns whether this node is a direct or indirect child of the $parentNode node.
Parameters
isSiblingOf
Returns whether this node, and the $child2Node node are are siblings (ie, they share the same parent).
Parameters
Last updated: Wed, 05 Dec 2007