\CGContactscategory

A class to represent a category within the CGContacts module.

Summary

Methods
Properties
Constants
is_child_of()
save()
load()
get_all()
get_list()
get_tree()
get_category_id()
get_category_name()
$id
$name
$description
$parent_id
$item_order
$hierarchy
$long_name
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$id

$id : int

The category id.

Type

int

$name

$name : string

The category name.

Type

string

$description

$description : string

The category description

Type

string

$parent_id

$parent_id : int

The id of this objects' parent. or -1

Type

int

$item_order

$item_order : int

The order of this object amongst it's peers.

Type

int

$hierarchy

$hierarchy : string

(read only) The hierarchy of this object (path to the root) expressed in category ids.

Type

string

$long_name

$long_name : string

(read only) The hierarchy of this object (path to the root) expressed in terms of category names.

Type

string

Methods

is_child_of()

is_child_of(int $a, int $b) : bool

Test if category A is a child of category B

Parameters

int $a

The first category id.

int $b

The second category id.

Returns

bool

save()

save(bool $update_positions)

Save this content object.

Parameters

bool $update_positions

A flag indicating wether or not to update hierarchy positions across all categories.

load()

load(int $id) : \CGContacts\category

Load the specified category object, given it's id.

Parameters

int $id

Returns

\CGContacts\category

get_all()

get_all() : array

Load all categories as a flat array.

Returns

array

get_list()

get_list() : array

Get the categories as a list suitable for use in a dropdown.

Returns

array

get_tree()

get_tree() : array

Get the categories as a tree.

Returns

array

get_category_id()

get_category_id(string $str) : int

Given a category name, attempt to find an id.

Parameters

string $str

Returns

int

get_category_name()

get_category_name(int $id) : string|null

Given a category id, get it's name

Parameters

int $id

Returns

string|null