Create event for directory_item hook

This commit is contained in:
Art4 2025-03-24 13:31:53 +00:00
parent 20a1d22620
commit 88929bb307
5 changed files with 20 additions and 3 deletions

View file

@ -15,6 +15,7 @@ use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\Core\Search;
use Friendica\DI;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Model;
use Friendica\Model\Profile;
use Friendica\Network\HTTPException;
@ -161,13 +162,22 @@ class Directory extends BaseModule
];
$hook = ['contact' => $contact, 'entry' => $entry];
$eventDispatcher = DI::eventDispatcher();
Hook::callAll('directory_item', $hook);
$hook_data = [
'contact' => $contact,
'entry' => $entry,
];
$hook_data = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::DIRECTORY_ITEM, $hook_data),
)->getArray();
$entry = $hook_data['entry'] ?? $entry;
unset($profile);
unset($location);
return $hook['entry'];
return $entry;
}
}