DownloadManagerCategories extends DownloadManagerModel
Download Manager Categories
Manages download categories
Table of Contents
Methods
| __construct() | Initialize |
| add() | Creates a category |
| delete() | Deletes the category and moves all child categories to this categories' parent along with this categories' files |
| edit() | Updates a category |
| get() | Fetches a specific category |
| getAll() | Fetches all categories |
| getAllParents() | Retrieves all parent categories for the given category, including the given category |
| getCategories() | Partially constructs a Record object for fetching categories |
| getRules() | Retrieves a list of rules to validate add/editing categories |
Methods
__construct()
Initialize
public
__construct() : mixed
add()
Creates a category
public
add(array<string|int, mixed> $vars) : stdClass
Parameters
- $vars : array<string|int, mixed>
-
A list of category input vars, including:
- parent_id The ID of the parent category to this category (optional, default null)
- name The name of the category
- description A description of this category
Tags
Return values
stdClass —An stdClass object representing the newly created category, or void on error
delete()
Deletes the category and moves all child categories to this categories' parent along with this categories' files
public
delete(int $category_id) : mixed
Parameters
- $category_id : int
-
The ID of the category to delete
edit()
Updates a category
public
edit(int $category_id, array<string|int, mixed> $vars) : stdClass
Parameters
- $category_id : int
-
The ID of the category to update
- $vars : array<string|int, mixed>
-
A list of category input vars, including:
- parent_id The ID of the parent category to this category (optional, default null)
- name The name of the category
- description A description of this category
Tags
Return values
stdClass —An stdClass object representing the category, or void on error
get()
Fetches a specific category
public
get(int $category_id) : mixed
Parameters
- $category_id : int
-
The ID of the category to fetch
Return values
mixed —An stdClass object representing the category, or false if one does not exist
getAll()
Fetches all categories
public
getAll(int $company_id[, int $parent_id = null ]) : array<string|int, mixed>
Parameters
- $company_id : int
-
The ID of the company from which to fetch categories
- $parent_id : int = null
-
The parent category ID whose categories to fetch
Return values
array<string|int, mixed> —A list of categories with the given parent ID
getAllParents()
Retrieves all parent categories for the given category, including the given category
public
getAllParents(int $category_id[, array<string|int, mixed> $exclude = [] ]) : array<string|int, mixed>
Parameters
- $category_id : int
-
The child category for which to retrieve parents for
- $exclude : array<string|int, mixed> = []
-
An array of parent categories to exclude from the results (optional, default empty array)
Return values
array<string|int, mixed> —A numerically-indexed array of categories ordered by the highest category down to, and including, the given category
getCategories()
Partially constructs a Record object for fetching categories
private
getCategories() : Record
Return values
Record —A partially-constructed Record object
getRules()
Retrieves a list of rules to validate add/editing categories
private
getRules(array<string|int, mixed> $vars[, bool $edit = false ]) : array<string|int, mixed>
Parameters
- $vars : array<string|int, mixed>
-
A list of input vars to validate
- $edit : bool = false
-
True to fetch the edit rules, false to fetch the add rules (optional, default false)
Return values
array<string|int, mixed> —A list of rules