Create event for profile_tabs hook

This commit is contained in:
Art4 2025-03-24 12:41:40 +00:00
parent f0273a618c
commit 20a1d22620
5 changed files with 15 additions and 4 deletions

View file

@ -9,9 +9,9 @@ namespace Friendica\Module;
use Friendica\BaseModule;
use Friendica\Content\Feature;
use Friendica\Core\Hook;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Event\ArrayFilterEvent;
use Friendica\Model\User;
class BaseProfile extends BaseModule
@ -128,12 +128,16 @@ class BaseProfile extends BaseModule
];
}
$arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
$hook_data = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $current, 'tabs' => $tabs];
Hook::callAll('profile_tabs', $arr);
$eventDispatcher = DI::eventDispatcher();
$hook_data = $eventDispatcher->dispatch(
new ArrayFilterEvent(ArrayFilterEvent::PROFILE_TABS, $hook_data),
)->getArray();
$tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
return Renderer::replaceMacros($tpl, ['$tabs' => $arr['tabs'], '$more' => DI::l10n()->t('More')]);
return Renderer::replaceMacros($tpl, ['$tabs' => $hook_data['tabs'], '$more' => DI::l10n()->t('More')]);
}
}