TreeNode implements ComparableNodeInterface, Serializable

Tree Node

Table of Contents

Interfaces

ComparableNodeInterface
Interface that defines the comparison of nodes
Serializable

Properties

$additionalData  : array<string|int, mixed>
$childNodes  : TreeNodeCollection|null
Child Nodes
$id  : string|int
Node Identifier
$parentNode  : TreeNode|null
Parent Node

Methods

__construct()  : mixed
Constructor
__serialize()  : array<string|int, mixed>
Returns class state to be serialized.
__unserialize()  : void
Fills the current node with the given serialized information
compareTo()  : int
Compares a node to another one.
dataFromArray()  : mixed
Sets data of the node by a given data array
equals()  : bool
Compares a node if it's identical to another node by the id property.
getAdditionalData()  : array<string|int, mixed>
getChildNodes()  : TreeNodeCollection
Returns child nodes collection
getId()  : string|int
Returns the identifier
getParentNode()  : TreeNode
Returns the parent node
hasChildNodes()  : bool
Returns TRUE if the node has child nodes attached
removeChildNodes()  : mixed
Removes child nodes collection
serialize()  : string
Returns the serialized instance
setChildNodes()  : mixed
Sets the child nodes collection
setId()  : mixed
Sets the identifier
setParentNode()  : mixed
Sets the parent node
toArray()  : array<string|int, mixed>
Returns the node in an array representation that can be used for serialization
unserialize()  : mixed
Create class state from serialized array.

Properties

$additionalData

protected array<string|int, mixed> $additionalData = []
Internal

This is part of the category tree performance hack.

$id

Node Identifier

protected string|int $id = ''

Methods

__construct()

Constructor

public __construct([array<string|int, mixed> $data = [] ]) : mixed

You can move an initial data array to initialize the instance and further objects. This is useful for the deserialization.

Parameters
$data : array<string|int, mixed> = []

__serialize()

Returns class state to be serialized.

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

Fills the current node with the given serialized information

public __unserialize(array<string|int, mixed> $arrayRepresentation) : void
Parameters
$arrayRepresentation : array<string|int, mixed>
Tags
throws
Exception

if the deserialized object type is not identical to the current one

compareTo()

Compares a node to another one.

public compareTo(TreeNode $other) : int

Returns: 1 if its greater than the other one -1 if its smaller than the other one 0 if its equal

Parameters
$other : TreeNode
Return values
int

See description above

dataFromArray()

Sets data of the node by a given data array

public dataFromArray(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

equals()

Compares a node if it's identical to another node by the id property.

public equals(TreeNode $other) : bool
Parameters
$other : TreeNode
Return values
bool

getAdditionalData()

public getAdditionalData() : array<string|int, mixed>
Internal

This is part of the category tree performance hack

Return values
array<string|int, mixed>

getId()

Returns the identifier

public getId() : string|int
Return values
string|int

hasChildNodes()

Returns TRUE if the node has child nodes attached

public hasChildNodes() : bool
Return values
bool

removeChildNodes()

Removes child nodes collection

public removeChildNodes() : mixed

serialize()

Returns the serialized instance

public serialize() : string
Tags
todo:

Drop method and \Serializable class interface in v12.

Return values
string

setId()

Sets the identifier

public setId(string|int $id) : mixed
Parameters
$id : string|int

setParentNode()

Sets the parent node

public setParentNode([TreeNode|null $parentNode = null ]) : mixed
Parameters
$parentNode : TreeNode|null = null

toArray()

Returns the node in an array representation that can be used for serialization

public toArray([bool $addChildNodes = true ]) : array<string|int, mixed>
Parameters
$addChildNodes : bool = true
Return values
array<string|int, mixed>

unserialize()

Create class state from serialized array.

public unserialize(string $serializedString) : mixed
Parameters
$serializedString : string
Tags
throws
Exception

if the deserialized object type is not identical to the current one

todo:

Drop method and \Serializable class interface in v12.


        
On this page

Search results