mirror of
https://github.com/friendica/friendica
synced 2025-03-03 20:28:26 +00:00
Create Event for contact_block_end hook
This commit is contained in:
parent
27a7735c65
commit
c66588cc2a
6 changed files with 15 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue