create event for profile_advanced hook

This commit is contained in:
Art4 2025-04-10 14:36:57 +00:00
parent 86ebbecff5
commit 3ea20e9eee
5 changed files with 31 additions and 4 deletions

View file

@ -113,6 +113,7 @@ final class HookEventBridge
HtmlFilterEvent::PAGE_END => 'page_end', HtmlFilterEvent::PAGE_END => 'page_end',
HtmlFilterEvent::MOD_HOME_CONTENT => 'home_content', HtmlFilterEvent::MOD_HOME_CONTENT => 'home_content',
HtmlFilterEvent::MOD_ABOUT_CONTENT => 'about_hook', HtmlFilterEvent::MOD_ABOUT_CONTENT => 'about_hook',
HtmlFilterEvent::MOD_PROFILE_CONTENT => 'profile_advanced',
HtmlFilterEvent::JOT_TOOL => 'jot_tool', HtmlFilterEvent::JOT_TOOL => 'jot_tool',
HtmlFilterEvent::CONTACT_BLOCK_END => 'contact_block_end', HtmlFilterEvent::CONTACT_BLOCK_END => 'contact_block_end',
]; ];
@ -201,6 +202,7 @@ final class HookEventBridge
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_HOME_CONTENT => 'onHtmlFilterEvent', HtmlFilterEvent::MOD_HOME_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_ABOUT_CONTENT => 'onHtmlFilterEvent', HtmlFilterEvent::MOD_ABOUT_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_PROFILE_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent', HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent',
HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent', HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent',
]; ];

View file

@ -30,6 +30,8 @@ final class HtmlFilterEvent extends Event
public const MOD_ABOUT_CONTENT = 'friendica.html.mod_about_content'; public const MOD_ABOUT_CONTENT = 'friendica.html.mod_about_content';
public const MOD_PROFILE_CONTENT = 'friendica.html.mod_profile_content';
public const JOT_TOOL = 'friendica.html.jot_tool'; public const JOT_TOOL = 'friendica.html.jot_tool';
public const CONTACT_BLOCK_END = 'friendica.html.contact_block_end'; public const CONTACT_BLOCK_END = 'friendica.html.contact_block_end';

View file

@ -17,13 +17,13 @@ use Friendica\Content\Nav;
use Friendica\Content\Text\BBCode; use Friendica\Content\Text\BBCode;
use Friendica\Content\Text\HTML; use Friendica\Content\Text\HTML;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook;
use Friendica\Core\L10n; use Friendica\Core\L10n;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Core\Session\Capability\IHandleUserSessions;
use Friendica\Database\Database; use Friendica\Database\Database;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Event\HtmlFilterEvent;
use Friendica\Model\Contact; use Friendica\Model\Contact;
use Friendica\Model\Profile as ProfileModel; use Friendica\Model\Profile as ProfileModel;
use Friendica\Model\Tag; use Friendica\Model\Tag;
@ -40,6 +40,7 @@ use Friendica\Util\Network;
use Friendica\Util\Profiler; use Friendica\Util\Profiler;
use Friendica\Util\Temporal; use Friendica\Util\Temporal;
use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Uri;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
class Profile extends BaseProfile class Profile extends BaseProfile
@ -56,9 +57,25 @@ class Profile extends BaseProfile
private $page; private $page;
/** @var ProfileField */ /** @var ProfileField */
private $profileField; private $profileField;
private EventDispatcherInterface $eventDispatcher;
public function __construct(ProfileField $profileField, Page $page, IManageConfigValues $config, IHandleUserSessions $session, AppHelper $appHelper, Database $database, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) public function __construct(
{ ProfileField $profileField,
Page $page,
IManageConfigValues $config,
IHandleUserSessions $session,
AppHelper $appHelper,
Database $database,
EventDispatcherInterface $eventDispatcher,
L10n $l10n,
BaseURL $baseUrl,
Arguments $args,
LoggerInterface $logger,
Profiler $profiler,
Response $response,
array $server,
array $parameters = [],
) {
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
$this->database = $database; $this->database = $database;
@ -67,6 +84,7 @@ class Profile extends BaseProfile
$this->config = $config; $this->config = $config;
$this->page = $page; $this->page = $page;
$this->profileField = $profileField; $this->profileField = $profileField;
$this->eventDispatcher = $eventDispatcher;
} }
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
@ -282,7 +300,9 @@ class Profile extends BaseProfile
], ],
]); ]);
Hook::callAll('profile_advanced', $o); $o = $this->eventDispatcher->dispatch(
new HTmlFilterEvent(HtmlFilterEvent::MOD_PROFILE_CONTENT, $o),
)->getHtml();
return $o; return $o;
} }

View file

@ -102,6 +102,7 @@ class HookEventBridgeTest extends TestCase
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_HOME_CONTENT => 'onHtmlFilterEvent', HtmlFilterEvent::MOD_HOME_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_ABOUT_CONTENT => 'onHtmlFilterEvent', HtmlFilterEvent::MOD_ABOUT_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::MOD_PROFILE_CONTENT => 'onHtmlFilterEvent',
HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent', HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent',
HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent', HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent',
]; ];
@ -612,6 +613,7 @@ class HookEventBridgeTest extends TestCase
[HtmlFilterEvent::PAGE_END, 'page_end'], [HtmlFilterEvent::PAGE_END, 'page_end'],
[HtmlFilterEvent::MOD_HOME_CONTENT, 'home_content'], [HtmlFilterEvent::MOD_HOME_CONTENT, 'home_content'],
[HtmlFilterEvent::MOD_ABOUT_CONTENT, 'about_hook'], [HtmlFilterEvent::MOD_ABOUT_CONTENT, 'about_hook'],
[HtmlFilterEvent::MOD_PROFILE_CONTENT, 'profile_advanced'],
[HtmlFilterEvent::JOT_TOOL, 'jot_tool'], [HtmlFilterEvent::JOT_TOOL, 'jot_tool'],
[HtmlFilterEvent::CONTACT_BLOCK_END, 'contact_block_end'], [HtmlFilterEvent::CONTACT_BLOCK_END, 'contact_block_end'],
]; ];

View file

@ -32,6 +32,7 @@ class HtmlFilterEventTest extends TestCase
[HtmlFilterEvent::PAGE_END, 'friendica.html.page_end'], [HtmlFilterEvent::PAGE_END, 'friendica.html.page_end'],
[HtmlFilterEvent::MOD_HOME_CONTENT, 'friendica.html.mod_home_content'], [HtmlFilterEvent::MOD_HOME_CONTENT, 'friendica.html.mod_home_content'],
[HtmlFilterEvent::MOD_ABOUT_CONTENT, 'friendica.html.mod_about_content'], [HtmlFilterEvent::MOD_ABOUT_CONTENT, 'friendica.html.mod_about_content'],
[HtmlFilterEvent::MOD_PROFILE_CONTENT, 'friendica.html.mod_profile_content'],
[HtmlFilterEvent::JOT_TOOL, 'friendica.html.jot_tool'], [HtmlFilterEvent::JOT_TOOL, 'friendica.html.jot_tool'],
[HtmlFilterEvent::CONTACT_BLOCK_END, 'friendica.html.contact_block_end'], [HtmlFilterEvent::CONTACT_BLOCK_END, 'friendica.html.contact_block_end'],
]; ];