RdbAdmin Module

Plugins
in package

Plugins class.

Tags
since
0.2.4

Table of Contents

Properties

$callbackHooks  : array<string|int, mixed>
$didHooks  : array<string|int, mixed>
$pluginsRegisteredHooks  : array<string|int, mixed>
$callbackHooks  : array<string|int, mixed>
$Container  : Container
$didHooks  : array<string|int, mixed>
$pluginsRegisteredHooks  : array<string|int, mixed>

Methods

__construct()  : mixed
Class constructor.
__get()  : mixed
Magic get.
addHook()  : mixed
Hooks a function onto a specific tag.
doAlter()  : mixed
Alter the data use callback function that have been added to a hook.
doHook()  : array<string|int, mixed>
Calls the callback function that have been added to a hook.
hasHook()  : bool|int
Check if any hook has been registered.
listPlugins()  : array<string|int, mixed>
List plugins
registerAllPluginsHooks()  : mixed
Register hooks for all enabled plugins.
removeAllHooks()  : mixed
Remove all the hooks.
removeHook()  : bool
Remove function from specified hook.
getHookIdHash()  : string
Get unique hook ID that is generate from arguments.

Properties

$callbackHooks read-only

public array<string|int, mixed> $callbackHooks

The array of callback hooks. The format is [$tag][$priority][$idHash]['callback' => 'callbackFunctionOrClass'].

$didHooks read-only

public array<string|int, mixed> $didHooks

The array of did callback hooks. The format is `[$tag][$priority][$idHash]['did' => true];

$pluginsRegisteredHooks read-only

public array<string|int, mixed> $pluginsRegisteredHooks

The array of plugin classes that was registered hooks.

$callbackHooks

protected array<string|int, mixed> $callbackHooks = []

The array of callback hooks. The format is [$tag][$priority][$idHash]['callback' => 'callbackFunctionOrClass'].

$Container

protected Container $Container

$didHooks

protected array<string|int, mixed> $didHooks = []

The array of did callback hooks. The format is `[$tag][$priority][$idHash]['did' => true];

$pluginsRegisteredHooks

protected array<string|int, mixed> $pluginsRegisteredHooks = []

The array of plugin classes that was registered hooks.

Methods

__construct()

Class constructor.

public __construct(Container $Container) : mixed

You maybe load this class via framework's Container object named Plugins. Example: $Plugins = $Container->get('Plugins');.
This is depended on if you extended your controller from Rdb\Modules\RdbAdmin\Controllers\BaseController.

Parameters
$Container : Container

The DI container class.

__get()

Magic get.

public __get(string $name) : mixed
Parameters
$name : string

addHook()

Hooks a function onto a specific tag.

public addHook(string $tag, string|array<string|int, mixed>|callable $callback[, int $priority = 10 ]) : mixed
Parameters
$tag : string

The name of hook.

$callback : string|array<string|int, mixed>|callable

The function or class to be called.

$priority : int = 10

Priority that function will be executed. Lower number will be execute earlier. Default is 10.

Tags
link

Copied from WordPress.

link

Copied from WordPress.

throws
InvalidArgumentException

Throw the exception if argument is wrong type or wrong value.

doAlter()

Alter the data use callback function that have been added to a hook.

public doAlter(string $tag, mixed $data, mixed ...$args) : mixed
Parameters
$tag : string

The name of hook.

$data : mixed

The data to alter.

$args : mixed

Additional parameters to pass to callback functions.

Tags
link

Argument description copied from WordPress.

since
1.2.5
Return values
mixed

The altered data after hooked all functions are applied to it.

doHook()

Calls the callback function that have been added to a hook.

public doHook(string $tag[, array<string|int, mixed> $args = [] ]) : array<string|int, mixed>
Parameters
$tag : string

The name of hook.

$args : array<string|int, mixed> = []

Additional arguments which are passed on to the function hooked. Default is empty.

Tags
link

Copied from Drupal.

link

How Drupal module/hook works.

Return values
array<string|int, mixed>

If there is no plugin hooks then it will be return $args argument.
If the plugin that hooked has nothing to return then it will be return empty array otherwise it will be return hooked results.

hasHook()

Check if any hook has been registered.

public hasHook(string $tag[, string|array<string|int, mixed>|callable $callback = false ]) : bool|int
Parameters
$tag : string

The name of hook.

$callback : string|array<string|int, mixed>|callable = false

The function or class callback to check for. Default is false.

Tags
link

Copied from WordPress.

throws
InvalidArgumentException

Throw the exception if argument is wrong type or wrong value.

Return values
bool|int

Return boolean if $callback is set to false. If $callback is check for specific function, the priority of that hook is returned, or return false if not found.

listPlugins()

List plugins

public listPlugins([array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed> = []

Available options:
availability (string) accept '' (empty string - means all), 'enabled', 'disabled'. Default is empty string.,
unlimited (bool) set to true to show unlimited items, unset or set to false to show limited items. Default is false.,
limit (int) limit items per page. maximum is 100.,
offset (int) offset or start at record. 0 is first record.,

Return values
array<string|int, mixed>

Return associative array with total and items in keys.

registerAllPluginsHooks()

Register hooks for all enabled plugins.

public registerAllPluginsHooks() : mixed

Register hooks for make it ready to use from the other parts of the application.
This method was called from \Rdb\Modules\RdbAdmin\Controllers\BaseController.

removeAllHooks()

Remove all the hooks.

public removeAllHooks(string $tag[, int|false $priority = false ]) : mixed
Parameters
$tag : string

The name of hook.

$priority : int|false = false

The priority number to remove. Set to false to remove all priorities. Default is false.

Tags
link

Copied from WordPress.

throws
InvalidArgumentException

Throw the exception if argument is wrong type or wrong value.

removeHook()

Remove function from specified hook.

public removeHook(string $tag, string|array<string|int, mixed>|callable $callback[, int $priority = 10 ]) : bool
Parameters
$tag : string

The name of hook.

$callback : string|array<string|int, mixed>|callable

The name of function which should be removed.

$priority : int = 10

The priority of the function. Default is 10.

Tags
link

Copied from WordPress.

throws
InvalidArgumentException

Throw the exception if argument is wrong type or wrong value.

Return values
bool

Return true if function is existed and removed, return false for otherwise.

getHookIdHash()

Get unique hook ID that is generate from arguments.

protected getHookIdHash(string $tag, string|array<string|int, mixed>|callable $callback) : string
Parameters
$tag : string

The name of hook.

$callback : string|array<string|int, mixed>|callable

The function or class to create unique ID.

Return values
string

Return hashed value.


        
On this page

Search results