TreeHelper

Extends \AppHelper

Helper for building tree

package

TreeHelper

subpackage

View.Helper

Methods

Recursively build tree in jquery-tree plugin format

_build(mixed $data, callable|string $getName, callable|string $getChildrens, integer $expandTo, integer $level, string $prefix = '') : string

Arguments

$data

mixed

Node childrens data

$getName

callable|string

Must return string node title from initial node data

$getChildrens

callable|string

Must return children nodes or null

$expandTo

integer

All nodes from 1 to $expandTo will be expanded initially

$level

integer

Current node nesting level

$prefix

string

Numeric dot-separated path from root to current node withoun current node number

Response

string

Html tree or empty string

Build scripts and styles

_buildAssets(boolean $inline) : string|void

Arguments

$inline

boolean

Response

string|void

Compiles callable from string (Hash path)

_toCallable(callable|string $callback) : callable
throws

If callback is not callable nor string

Arguments

$callback

callable|string

Response

callable

Build tree in jquery-tree plugin format

build(mixed $data, array $options = array()) : string

Arguments

$data

mixed

Data for building tree

$options

array

Options, can be:

  • getName string|callable Function for getting string representation of node
  • getChildrens string|callable Function for getting childrens of node
  • expandTo int All nodes from 1 to $expandTo will be expanded initially
  • inline bool Should be scripts and styles inline or not

Response

string

Html tree with scripts and styles (if inline)

Properties

Used helpers

helpers : array
var

Type(s)

array

Html

Html : \HtmlHelper

Html helper

Type(s)

\HtmlHelper

Form

Form : \FormHelper

Form helper

Type(s)

\FormHelper