Documentation

IntegrationHook
in package

Handles adding, removing, and calling hooked integration functions.

Table of Contents

Properties

$ignore_errors  : bool
$name  : string
$results  : array<string|int, mixed>
$callables  : array<string|int, mixed>

Methods

__construct()  : mixed
Constructor.
add()  : void
Adds a function or method to an integration hook.
call()  : array<string|int, mixed>
Convenience method to create and execute an instance of this class.
execute()  : array<string|int, mixed>
Executes all the callables in $this->callables, passing the $parameters to each one.
remove()  : void
Removes an integration hook function.

Properties

$ignore_errors

public bool $ignore_errors = false

If true, silently skip hooked functions that are not callable.

$results

public array<string|int, mixed> $results = []

The results from executing this hook.

$callables

private array<string|int, mixed> $callables = []

The callables to execute for this hook.

Methods

__construct()

Constructor.

public __construct(string $name[, bool $ignore_errors = null ]) : mixed
Parameters
$name : string

The name of the integration hook.

$ignore_errors : bool = null

If true, silently skip hooked functions that are not callable. Defaults to Utils::$context['ignore_hook_errors'].

add()

Adds a function or method to an integration hook.

public static add(string $name, string $function[, bool $permanent = true ][, string $file = '' ][, bool $object = false ]) : void

Does nothing if the function is already added. Cleans up enabled/disabled variants before taking requested action.

Parameters
$name : string

The complete hook name.

$function : string

The function name. Can be a call to a method via Class::method.

$permanent : bool = true

If true, updates the value in settings table.

$file : string = ''

The filename. Must include one of the following wildcards: $boarddir, $sourcedir, $themedir. Example: $sourcedir/Test.php

$object : bool = false

Indicates if your class will be instantiated when its respective hook is called. If true, your function must be a method.

call()

Convenience method to create and execute an instance of this class.

public static call(string $name[, array<string|int, mixed> $parameters = [] ]) : array<string|int, mixed>
Parameters
$name : string

The name of the integration hook.

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

Parameters to pass to the hooked callables.

Return values
array<string|int, mixed>

The results returned by all the hooked callables.

execute()

Executes all the callables in $this->callables, passing the $parameters to each one.

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

Parameters to pass to the hooked callables.

Return values
array<string|int, mixed>

The results returned by all the hooked callables.

remove()

Removes an integration hook function.

public static remove(string $name, string $function[, bool $permanent = true ][, string $file = '' ][, bool $object = false ]) : void

Removes the given function from the given hook. Does nothing if the function is not available. Cleans up enabled/disabled variants before taking requested action.

Parameters
$name : string

The complete hook name.

$function : string

The function name. Can be a call to a method via Class::method.

$permanent : bool = true

Irrelevant for the function itself but need to declare it to match.

$file : string = ''

The filename. Must include one of the following wildcards: $boarddir, $sourcedir, $themedir. Example: $sourcedir/Test.php

$object : bool = false

Indicates if your class will be instantiated when its respective hook is called. If true, your function must be a method.

Tags
see
IntegrationHook::add

        
On this page

Search results