Documentation
Class libraries
addons
addons class library is the main concept in toKernel framework for accessing and working with addons.
File: tokernel.framework/lib/addons.lib.php
Usage of addons
$name = $this->lib->addons->user->get_name();
This example demonstrates how to access addon user's method get_name().
$article_obj = $this->lib->addons->article->instance();
This example demonstrates how to get a clone of 'articles' addon object.
Library methods
array all([bool $tk_only = false])
Return array of all addons with names. If the argument $tk_only is true, this method will return only addons array from /tokernel.framework/addons/
$addons = $this->lib->addons->all();
/*
Returns addon names from: /tokernel.framework/addons/ and /application/addons/
array(
0 => 'users',
1 => 'articles',
2 => 'datatable',
3 => 'admin'
)
*/
$addons = $this->lib->addons->all(true);
/*
Returns addon names only from: /tokernel.framework/addons/
array(
0 => 'users',
1 => 'admin',
)
*/
bool exist(string $id_addon [, bool $custom_only = false])
Returns true if the given addon exists. If the argument $custom_only is true, this method will check addon only in /application/addons/ directory.
$ae = $this->lib->addons->exist('user');
object load(string $id_addon [, array $params = array()])
Load an addon and return object.
$user_obj = $this->lib->addons->load('user');
// Same as:
$user_obj = $this->lib->addons->user;
If addon have the instance method, and we calling it as:
$user = $this->lib->addons->user->instance();
it will return a new cloned copy of user object.
In all other cases will return already loaded addon object.
array | bool loaded([string $id_addon = NULL])
If the argument $id_addon is null returns array with names of loaded addons. Else, return true if given addon is already loaded.
$array_of_loaded_addons = $this->lib->addons->loaded();
/*
Array with names of loaded addons.
array(
0 => 'user',
1 => 'articles'
)
*/
$loaded = $this->lib->addons->loaded('articles');
// This will return true or false.