mirror of
https://github.com/friendica/friendica
synced 2025-05-05 23:04:09 +02:00
Move hook-related methods from Core\Addon to Core\Hook
This commit is contained in:
parent
0aa7671119
commit
ca9cad3491
9 changed files with 153 additions and 242 deletions
|
@ -7,6 +7,7 @@ namespace Friendica\Worker;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -45,7 +46,7 @@ class Cron
|
|||
logger('cron: start');
|
||||
|
||||
// Fork the cron jobs in separate parts to avoid problems when one of them is crashing
|
||||
Addon::forkHooks($a->queue['priority'], "cron");
|
||||
Hook::fork($a->queue['priority'], "cron");
|
||||
|
||||
// run queue delivery process in the background
|
||||
Worker::add(PRIORITY_NEGLIGIBLE, "Queue");
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -17,13 +17,13 @@ require_once 'include/dba.php';
|
|||
|
||||
class Expire
|
||||
{
|
||||
public static function execute($param = '', $hook_name = '')
|
||||
public static function execute($param = '', $hook_function = '')
|
||||
{
|
||||
$a = BaseObject::getApp();
|
||||
|
||||
require_once 'include/items.php';
|
||||
|
||||
Addon::loadHooks();
|
||||
Hook::loadHooks();
|
||||
|
||||
if ($param == 'delete') {
|
||||
logger('Delete expired items', LOGGER_DEBUG);
|
||||
|
@ -62,11 +62,11 @@ class Expire
|
|||
logger('Expire items for user '.$user['uid'].' ('.$user['username'].') - done ', LOGGER_DEBUG);
|
||||
}
|
||||
return;
|
||||
} elseif (!empty($hook_name) && ($param == 'hook') && is_array($a->hooks) && array_key_exists("expire", $a->hooks)) {
|
||||
foreach ($a->hooks["expire"] as $hook) {
|
||||
if ($hook[1] == $hook_name) {
|
||||
} elseif ($param == 'hook' && !empty($hook_function)) {
|
||||
foreach (Hook::getByName('expire') as $hook) {
|
||||
if ($hook[1] == $hook_function) {
|
||||
logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Addon::callSingleHook($a, $hook_name, $hook, $data);
|
||||
Hook::callSingle($a, 'expire', $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -86,13 +86,10 @@ class Expire
|
|||
DBA::close($r);
|
||||
|
||||
logger('expire: calling hooks');
|
||||
|
||||
if (is_array($a->hooks) && array_key_exists('expire', $a->hooks)) {
|
||||
foreach ($a->hooks['expire'] as $hook) {
|
||||
logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Expire', 'hook', $hook[1]);
|
||||
}
|
||||
foreach (Hook::getByName('expire') as $hook) {
|
||||
logger("Calling expire hook for '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
Worker::add(['priority' => $a->queue['priority'], 'created' => $a->queue['created'], 'dont_fork' => true],
|
||||
'Expire', 'hook', $hook[1]);
|
||||
}
|
||||
|
||||
logger('expire: end');
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
|
||||
Class ForkHook
|
||||
{
|
||||
|
@ -13,6 +13,6 @@ Class ForkHook
|
|||
{
|
||||
$a = \Friendica\BaseObject::getApp();
|
||||
|
||||
Addon::callSingleHook($a, $name, $hook, $data);
|
||||
Hook::callSingle($a, $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,12 @@ namespace Friendica\Worker;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\PushSubscriber;
|
||||
|
@ -20,7 +22,6 @@ use Friendica\Protocol\ActivityPub;
|
|||
use Friendica\Protocol\Diaspora;
|
||||
use Friendica\Protocol\OStatus;
|
||||
use Friendica\Protocol\Salmon;
|
||||
use Friendica\Model\Conversation;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
require_once 'include/items.php';
|
||||
|
@ -501,7 +502,7 @@ class Notifier
|
|||
logger('notifier: calling hooks for ' . $cmd . ' ' . $item_id, LOGGER_DEBUG);
|
||||
|
||||
if ($normal_mode) {
|
||||
Addon::forkHooks($a->queue['priority'], 'notifier_normal', $target_item);
|
||||
Hook::fork($a->queue['priority'], 'notifier_normal', $target_item);
|
||||
}
|
||||
|
||||
Addon::callHooks('notifier_end',$target_item);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue