Replace hooks post_local_start, post_local and post_local_end with EventDispatcher

This commit is contained in:
Art4 2025-02-08 08:17:30 +00:00
parent 649ddf7ab9
commit aabf9a8b01
4 changed files with 48 additions and 22 deletions

View file

@ -24,6 +24,7 @@ use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\Contact;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
@ -43,7 +44,11 @@ function item_post()
item_drop($uid, $_REQUEST['dropitems']);
}
Hook::callAll('post_local_start', $_REQUEST);
$eventDispatcher = DI::eventDispatcher();
$_REQUEST = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL_START, $_REQUEST)
)->getArray();
$return_path = $_REQUEST['return'] ?? '';
$preview = intval($_REQUEST['preview'] ?? 0);
@ -275,7 +280,11 @@ function item_process(array $post, array $request, bool $preview, string $return
System::jsonExit(['preview' => $o]);
}
Hook::callAll('post_local', $post);
$eventDispatcher = DI::eventDispatcher();
$post = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::POST_LOCAL, $post)
)->getArray();
unset($post['edit']);
unset($post['self']);