mirror of
https://github.com/friendica/friendica
synced 2025-04-23 22:30:10 +00:00
Hook calls can now be forked into a worker queue entry
This commit is contained in:
parent
66e3c1836e
commit
47d165cb25
9 changed files with 47 additions and 68 deletions
|
@ -6,6 +6,7 @@ namespace Friendica\Core;
|
|||
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Core\Worker;
|
||||
|
||||
use dba;
|
||||
|
||||
|
@ -185,6 +186,25 @@ class Addon
|
|||
dba::close($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Forks a hook.
|
||||
*
|
||||
* Use this function when you want to fork a hook via the worker.
|
||||
*
|
||||
* @param string $name of the hook to call
|
||||
* @param string|array $data to transmit to the callback handler
|
||||
*/
|
||||
public static function ForkHooks($priority, $name, $data = null)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) {
|
||||
foreach ($a->hooks[$name] as $hook) {
|
||||
Worker::add($priority, 'ForkHook', $name, json_encode($hook), json_encode($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Calls a hook.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue