phpBB API Documentation
Interface

phpbb\tree\tree_interface

interface tree_interface

Methods

array insert(array $additional_data)

Inserts an item into the database table and into the tree.

array delete(int $item_id)

Delete an item from the tree and from the database table

bool move(int $item_id, int $delta)

Move an item by a given delta

bool move_down(int $item_id)

Move an item down by 1

bool move_up(int $item_id)

Move an item up by 1

bool move_children(int $current_parent_id, int $new_parent_id)

Moves all children of one item to another item

bool change_parent(int $item_id, int $new_parent_id)

Change parent item

array get_path_and_subtree_data(int $item_id, bool $order_asc, bool $include_item)

Get all items that are either ancestors or descendants of the item

array get_path_data(int $item_id, bool $order_asc, bool $include_item)

Get all of the item's ancestors

array get_subtree_data(int $item_id, bool $order_asc, bool $include_item)

Get all of the item's descendants

Details

at line 24
public array insert(array $additional_data)

Inserts an item into the database table and into the tree.

Parameters

array $additional_data The item to be added

Return Value

array Array with item data as set in the database

at line 34
public array delete(int $item_id)

Delete an item from the tree and from the database table

Also deletes the subtree from the tree and from the database table

Parameters

int $item_id The item to be deleted

Return Value

array Item ids that have been deleted

at line 47
public bool move(int $item_id, int $delta)

Move an item by a given delta

An item is only moved up/down within the same parent. If the delta is larger then the number of children, the item is moved to the top/bottom of the list of children within this parent.

Parameters

int $item_id The item to be moved
int $delta Number of steps to move this item, < 0 => down, > 0 => up

Return Value

bool True if the item was moved

at line 55
public bool move_down(int $item_id)

Move an item down by 1

Parameters

int $item_id The item to be moved

Return Value

bool True if the item was moved

at line 63
public bool move_up(int $item_id)

Move an item up by 1

Parameters

int $item_id The item to be moved

Return Value

bool True if the item was moved

at line 75
public bool move_children(int $current_parent_id, int $new_parent_id)

Moves all children of one item to another item

If the new parent already has children, the new children are appended to the list.

Parameters

int $current_parent_id The current parent item
int $new_parent_id The new parent item

Return Value

bool True if any items where moved

at line 86
public bool change_parent(int $item_id, int $new_parent_id)

Change parent item

Moves the item to the bottom of the new \parent's list of children

Parameters

int $item_id The item to be moved
int $new_parent_id The new parent item

Return Value

bool True if the parent was set successfully

at line 97
public array get_path_and_subtree_data(int $item_id, bool $order_asc, bool $include_item)

Get all items that are either ancestors or descendants of the item

Parameters

int $item_id Id of the item to retrieve the ancestors/descendants from
bool $order_asc Order the items ascendingly (most outer ancestor first)
bool $include_item Should the item matching the given item id be included in the list as well

Return Value

array Array of items (containing all columns from the item table) ID => Item data

at line 108
public array get_path_data(int $item_id, bool $order_asc, bool $include_item)

Get all of the item's ancestors

Parameters

int $item_id Id of the item to retrieve the ancestors from
bool $order_asc Order the items ascendingly (most outer ancestor first)
bool $include_item Should the item matching the given item id be included in the list as well

Return Value

array Array of items (containing all columns from the item table) ID => Item data

at line 119
public array get_subtree_data(int $item_id, bool $order_asc, bool $include_item)

Get all of the item's descendants

Parameters

int $item_id Id of the item to retrieve the descendants from
bool $order_asc Order the items ascendingly
bool $include_item Should the item matching the given item id be included in the list as well

Return Value

array Array of items (containing all columns from the item table) ID => Item data