X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FAddon.php;h=a3bfeec32b34a9745b7acea18c8940b8675186d7;hb=c181f234a99787a17e5cc3481b4579eb84787c3b;hp=a721bd67eaba16443a509de64186ea9af594aa87;hpb=66e3c1836ea8ddfea9b5dc60ce9617d49696323b;p=friendica.git diff --git a/src/Core/Addon.php b/src/Core/Addon.php index a721bd67ea..a3bfeec32b 100644 --- a/src/Core/Addon.php +++ b/src/Core/Addon.php @@ -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, $hook, $data); + } + } + } + /** * @brief Calls a hook. *