ezcTreeNode represents a node in a tree.
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:
To use your own implementation of tree nodes, you can override the class that is used by the tree by setting the nodeClassName property of the ezcTree class. The class must inherit from this class though.
Source for this file: /Tree/src/tree_node.php
Version: | //autogentag// |
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 |
public ezcTreeNode |
__construct(
$tree
, $nodeId
, $data
)
Constructs a new ezcTreeNode object with ID $nodeId on tree $tree. |
public void |
accept(
$visitor
)
Implements the accept method for visiting. |
public void |
addChild(
$node
)
Adds the node $node as child of the current node to the tree. |
public ezcTreeNodeList |
fetchChildren(
)
Returns all the children of this node. |
public ezcTreeNode |
fetchParent(
)
Returns the parent node of this node. |
public ezcTreeNodeList |
fetchPath(
)
Returns all the nodes in the path from the root node to this node. |
public ezcTreeNodeList |
fetchSubtree(
)
Alias for fetchSubtreeDepthFirst(). |
public ezcTreeNodeList |
fetchSubtreeBreadthFirst(
)
Returns this node and all its children, sorted accoring to the Breadth-first sorting algorithm. |
public ezcTreeNodeList |
fetchSubtreeDepthFirst(
)
Returns this node and all its children, sorted according to the Depth-first sorting algorithm. |
public int |
getChildCount(
)
Returns the number of direct children of this node. |
public int |
getChildCountRecursive(
)
Returns the number of children of this node, recursively iterating over the children. |
public int |
getPathLength(
)
Returns the distance from the root node to this node. |
public bool |
hasChildNodes(
)
Returns whether this node has children. |
public void |
injectData(
$data
)
Inject data. |
public bool |
isChildOf(
$parentNode
)
Returns whether this node is a direct child of the $parentNode node. |
public bool |
isDescendantOf(
$parentNode
)
Returns whether this node is a direct or indirect child of the $parentNode node. |
public bool |
isSiblingOf(
$child2Node
)
Returns whether this node, and the $child2Node node are are siblings (ie, they share the same parent). |
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.
Name | Type | Description |
---|---|---|
$tree |
ezcTree | |
$nodeId |
string | |
$data |
mixed |
Implements the accept method for visiting.
Name | Type | Description |
---|---|---|
$visitor |
ezcTreeVisitor |
Method | Description |
---|---|
ezcTreeVisitable::accept() |
Accepts the visitor. |
Adds the node $node as child of the current node to the tree.
Name | Type | Description |
---|---|---|
$node |
ezcTreeNode |
Returns all the children of this node.
Returns the parent node of this node.
Returns all the nodes in the path from the root node to this node.
Alias for fetchSubtreeDepthFirst().
Returns this node and all its children, sorted accoring to the Breadth-first sorting algorithm.
Returns this node and all its children, sorted according to the Depth-first sorting algorithm.
Returns the number of direct children of this node.
Returns the number of children of this node, recursively iterating over the children.
Returns the distance from the root node to this node.
Returns whether this node has children.
Inject data.
Used to set the data from a data loader. Should not be used for interfacing with the tree node, since the node will not be flagged as modified by this method.
Name | Type | Description |
---|---|---|
$data |
string |
Returns whether this node is a direct child of the $parentNode node.
Name | Type | Description |
---|---|---|
$parentNode |
ezcTreeNode |
Returns whether this node is a direct or indirect child of the $parentNode node.
Name | Type | Description |
---|---|---|
$parentNode |
ezcTreeNode |
Returns whether this node, and the $child2Node node are are siblings (ie, they share the same parent).
Name | Type | Description |
---|---|---|
$child2Node |
ezcTreeNode |