diff --git a/doc/Addons.md b/doc/Addons.md index 70b51c3066..7b7e97e701 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -661,7 +661,7 @@ Called when a custom storage is used (e.g. webdav_storage) Hook data: - **name** (input): the name of the used storage backend -- **data['storage']** (output): the storage instance to use (**must** implement `\Friendica\Core\Storage\IWritableStorage`) +- **data['storage']** (output): the storage instance to use (**must** implement `\Friendica\Core\Storage\IWritableStorage`) ### storage_config @@ -876,7 +876,7 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep- ### src/Content/ContactBlock.php - Hook::callAll('contact_block_end', $arr); + Hook::callAll('contact_block_end', $text); ### src/Content/Text/BBCode.php diff --git a/doc/de/Addons.md b/doc/de/Addons.md index 607f2d50dc..bfc0107528 100644 --- a/doc/de/Addons.md +++ b/doc/de/Addons.md @@ -359,10 +359,10 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap Hook::callAll('register_account', $uid); Hook::callAll('remove_user', $user); - + ### src/Content/ContactBlock.php - Hook::callAll('contact_block_end', $arr); + Hook::callAll('contact_block_end', $text); ### src/Content/Text/BBCode.php diff --git a/src/Content/Widget/ContactBlock.php b/src/Content/Widget/ContactBlock.php index b1d80653d4..2a9d14db3e 100644 --- a/src/Content/Widget/ContactBlock.php +++ b/src/Content/Widget/ContactBlock.php @@ -8,11 +8,11 @@ namespace Friendica\Content\Widget; use Friendica\Content\Text\HTML; -use Friendica\Core\Hook; use Friendica\Core\Protocol; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; +use Friendica\Event\HtmlFilterEvent; use Friendica\Model\Contact; use Friendica\Model\User; @@ -26,7 +26,6 @@ class ContactBlock /** * Get HTML for contact block * - * @hook contact_block_end (contacts=>array, output=>string) * @return string Formatted HTML code or empty string */ public static function getHTML(array $profile, int $visitor_uid = null): string @@ -113,9 +112,11 @@ class ContactBlock '$micropro' => $micropro, ]); - $arr = ['contacts' => $contacts, 'output' => $o]; + $eventDispatcher = DI::eventDispatcher(); - Hook::callAll('contact_block_end', $arr); + $o = $eventDispatcher->dispatch( + new HtmlFilterEvent(HtmlFilterEvent::CONTACT_BLOCK_END, $o), + )->getHtml(); return $o; } diff --git a/src/Core/Hooks/HookEventBridge.php b/src/Core/Hooks/HookEventBridge.php index bc0615f368..943ba7eaa6 100644 --- a/src/Core/Hooks/HookEventBridge.php +++ b/src/Core/Hooks/HookEventBridge.php @@ -64,6 +64,7 @@ final class HookEventBridge HtmlFilterEvent::PAGE_CONTENT_TOP => 'page_content_top', HtmlFilterEvent::PAGE_END => 'page_end', HtmlFilterEvent::JOT_TOOL => 'jot_tool', + HtmlFilterEvent::CONTACT_BLOCK_END => 'contact_block_end', ]; /** @@ -101,6 +102,7 @@ final class HookEventBridge HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent', HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent', + HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent', ]; } diff --git a/src/Event/HtmlFilterEvent.php b/src/Event/HtmlFilterEvent.php index 83a852e08b..cb8a3992df 100644 --- a/src/Event/HtmlFilterEvent.php +++ b/src/Event/HtmlFilterEvent.php @@ -28,6 +28,8 @@ final class HtmlFilterEvent extends Event public const JOT_TOOL = 'friendica.html.jot_tool'; + public const CONTACT_BLOCK_END = 'friendica.html.contact_block_end'; + private string $html; public function __construct(string $name, string $html) diff --git a/tests/Unit/Core/Hooks/HookEventBridgeTest.php b/tests/Unit/Core/Hooks/HookEventBridgeTest.php index e7d7aba55e..b8fb3c4814 100644 --- a/tests/Unit/Core/Hooks/HookEventBridgeTest.php +++ b/tests/Unit/Core/Hooks/HookEventBridgeTest.php @@ -53,6 +53,7 @@ class HookEventBridgeTest extends TestCase HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent', HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent', HtmlFilterEvent::JOT_TOOL => 'onHtmlFilterEvent', + HtmlFilterEvent::CONTACT_BLOCK_END => 'onHtmlFilterEvent', ]; $this->assertSame( @@ -302,6 +303,7 @@ class HookEventBridgeTest extends TestCase [HtmlFilterEvent::PAGE_CONTENT_TOP, 'page_content_top'], [HtmlFilterEvent::PAGE_END, 'page_end'], [HtmlFilterEvent::JOT_TOOL, 'jot_tool'], + [HtmlFilterEvent::CONTACT_BLOCK_END, 'contact_block_end'], ]; }