InfinityTree

package

Default

Methods

Constructor If you want, you can create your own adapters based on the interfaces

__construct(array $config = array(), \InfinityTree\Interfaces\Storage $storage = null, \InfinityTree\Interfaces\Validation $validation = null) 

Arguments

$config

array

Config array, optinal, rewrites rules loaded from file

$storage

\InfinityTree\Interfaces\Storage

The adapter for the storage

$validation

\InfinityTree\Interfaces\Validation

The validation adapter

Creates a node and adds it to the initialized tree

addNode(integer $parent = null, string $name) : \InfinityTree\Node

Arguments

$parent

integer

The parent node's ID to add to

$name

string

Name of the node

Response

\InfinityTree\Node

Returns the created node

Converts a tree into html or other formats

convertTo(array $tree, string $to, \InfinityTree\Interfaces\Conversion $conversion = null) : mixed

Arguments

$tree

array

The tree in array format

$to

string

The param that decides the output

$conversion

\InfinityTree\Interfaces\Conversion

If you want, you can pass your own conversion class, it just has to implement the interface

Response

mixed

Returns the output in the format required

Deletes a node

deleteNode(integer $id, boolean $delete_subtree = false) : boolean

Arguments

$id

integer

The id of the node

$delete_subtree

boolean

If true, deletes the whole subtree, otherwise moves subtree to root

Response

boolean

Find a node by ID, slug or name

findNode(mixed $by) : array

Arguments

$by

mixed

Can be either the id, the slug or the name of the node

Response

array

Returns all the found nodes or empty array if none found

getErrors

getErrors() 

Initializes a tree It is important to do so, otherwise the default tree is used with the id of 1 This makes possible to have more trees, like categories and chapters with one library

initTree(integer $id) 

Arguments

$id

integer

The id of the tree you want to use

Moves a node under another node Can be moved under the same parent with the goal of changing order

moveNode(integer $node, integer $to, integer $order = 1) : boolean

Arguments

$node

integer

Id of the node to move

$to

integer

Id of the node to move to, root if null

$order

integer

The place of the moved node on the level it is on Use order like: 2, this means the node will be moved to the second place

Response

boolean

Returns the tree beginning from given root id

treeAsArray(integer $root = null, boolean $flat = false) : array

Arguments

$root

integer

The node to start the tree from

$flat

boolean

If true, it returns all the children of a given root in a flat array

Response

array

Updates the name of the node by id

updateNode(integer $id, string $name) : boolean

Arguments

$id

integer

The id of the node to update (cannot be root)

$name

string

The new name of the node

Response

boolean

Properties

Holds the configuration array for this library

_config : array
var

Holds the configuration array for this library

Type(s)

array

Holds the implemented storage adapter

_storage : \InfnityTree\Interfaces\Storage
var

Holds the implemented storage adapter

Type(s)

\InfnityTree\Interfaces\Storage

Holds the implemented validation adapter

_validation : \InfinityTree\Interfaces\Validation
var

Holds the implemented validation adapter

Type(s)

\InfinityTree\Interfaces\Validation

Holds the tree we work on

_tree : \InfinityTree\Tree
var

Holds the tree we work on

Type(s)

\InfinityTree\Tree

An associative array with the errors happening during tree handling

_errors : array
var

An associative array with the errors happening during tree handling

Type(s)

array