Nodes of a {@link Tree} structure.

While the Tree is the overarching container of the nodes. The nodes themselves are the actual structure and organisation and contain the members. The members are usually programmer created objects which impliment TreeNodeMemberInterface. Maximum level of nodes = 255

package dstruct_tree
author David

 Methods

Class constructor

__construct(array $row) 

Parameters

$row

array

Data to populate object with.

Add a child directly to the node.

addChild() 
todo Impliment addChild()

Does node accept members?

getAcceptsMembers() : boolean
see \setAcceptsMembers()

Returns

boolean

Get any children of the node.

getChildren() : \TreeNodes

Returns

Get the ID of the node.

getID() : integer

Returns

integer

Get the depth of the node within the structure.

getLevel() : integer

Maximum allowable level is 255.

Returns

integer

Get the name of the node.

getName(string $raw) : string

Parameters

$raw

string

HTML encoded or raw.

Returns

string

Get the nodes which form the path to this node.

getNodesToRoot() : \TreeNodes
todo Impliment getNodesToRoot()

Returns

Get the parent of this node.

getParent() : object

Returns

object

Get the ID of the parent of this node.

getParentID() : integer

Returns

integer

Get nodes from the part of the Tree structure.

getSiblings() 
todo Impliment getSiblings()

Get the sort order of the node.

getSortOrder() : \number

Trees can be ordered and given preference in the syste. A lower number is a higher preference.

todo Define the acceptable range

Returns

\number

Get the Tree this node belongs to.

getTree() : \Tree

Returns

Get the ID of the Tree this node belongs to.

getTreeID() : integer

Returns

integer

Does this node have any children?

hasChildren() : boolean

Returns

boolean

Load the TreeNode by its ID

loadByID(integer $id, array $row) : false | \TreeNode
Static

Parameters

$id

integer

ID of object to load

$row

array

Data to populate object

Returns

false\TreeNodeFalse if can't find object with that ID

Save the node in the database.

save() 

Set whether this node accepts members.

setAcceptsMembers(boolean $accepts) 

Nodes will usually be populated with members which are defined by the user and impliment TreeNodeMemberInterface. It may be desirable to restrict the ability for members to be added to a node, however, Set this to false to stop any members being added.

Parameters

$accepts

boolean

Set the name of the node.

setName(string $name) 

Parameters

$name

string

Set the parent node, if any.

setParent(\TreeNode | integer $parent) 

Parameters

$parent

\TreeNodeinteger

Object or its ID

Exceptions

\DStructGeneralException

Set the sort order of the node.

setSortOrder(integer $sortorder) 

Nodes can be ordered and given preference in the system. A lower number is a higher preference.

todo Define the acceptable range

Parameters

$sortorder

integer

Exceptions

\DStructGeneralException

Set the Tree this node belongs to.

setTree(\Tree | integer $tree) 

Parameters

$tree

\Treeinteger

The Tree object or its ID

Insert into database.

insert() 

Lazy loader for the children of this node.

loadChildren() 

Lazy loader for the parent of this node.

loadParent() 

Lazy loader for the Tree of this node.

loadTree() 

Update the node in the database.

update() 

 Properties

 

$acceptsmembers : integer
 

$children : \TreeNodes
 

$id : integer
 

$level : integer
 

$members : Object
 

$name : string
 

$parent : object
 

$parentid : integer
 

$sortorder : integer
 

$tree : \Tree
 

$treeid : integer