Zeta Components Manual :: Docs For Class ezcTreeNode
Tree::ezcTreeNode
Class ezcTreeNode
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:
- <?php
- // Creates a new node with ID 'O' and as data 'Oxygen'
- // Adds a node as child element to another already create node in a tree
- ?>
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
Implements interfaces:
Version: | //autogentag// |
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
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). |
Methods
__construct
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:
Name | Type | Description |
---|---|---|
$visitor |
ezcTreeVisitor |
Implementation of:
Method | Description |
---|---|
ezcTreeVisitable::accept() |
Accepts the visitor. |
addChild
Adds the node $node as child of the current node to the tree.
Parameters:
Name | Type | Description |
---|---|---|
$node |
ezcTreeNode |
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().
fetchSubtreeBreadthFirst
Returns this node and all its children, sorted accoring to the Breadth-first sorting algorithm.
fetchSubtreeDepthFirst
Returns this node and all its children, sorted according to the Depth-first sorting algorithm.
getChildCount
Returns the number of direct children of this node.
getChildCountRecursive
Returns the number of children of this node, recursively iterating over the children.
getPathLength
Returns the distance from the root node to this node.
hasChildNodes
Returns whether this node has children.
injectData
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.
Parameters:
Name | Type | Description |
---|---|---|
$data |
string |
isChildOf
Returns whether this node is a direct child of the $parentNode node.
Parameters:
Name | Type | Description |
---|---|---|
$parentNode |
ezcTreeNode |
isDescendantOf
Returns whether this node is a direct or indirect child of the $parentNode node.
Parameters:
Name | Type | Description |
---|---|---|
$parentNode |
ezcTreeNode |
isSiblingOf
Returns whether this node, and the $child2Node node are are siblings (ie, they share the same parent).
Parameters:
Name | Type | Description |
---|---|---|
$child2Node |
ezcTreeNode |