mirror of
https://github.com/friendica/friendica
synced 2025-03-03 19:48:26 +00:00
create event for render_location hook
This commit is contained in:
parent
85fceaa16e
commit
b3ef18bed7
5 changed files with 18 additions and 6 deletions
|
@ -14,7 +14,6 @@ use Friendica\App\Page;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig\Capability\IManagePersonalConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
|
@ -1472,7 +1471,11 @@ class Conversation
|
|||
}
|
||||
|
||||
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
|
||||
Hook::callAll('render_location', $locate);
|
||||
|
||||
$locate = $this->eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::RENDER_LOCATION, $locate),
|
||||
)->getArray();
|
||||
|
||||
$location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: '');
|
||||
|
||||
$this->item->localize($item);
|
||||
|
|
|
@ -50,6 +50,7 @@ final class HookEventBridge
|
|||
ArrayFilterEvent::NETWORK_TO_NAME => 'network_to_name',
|
||||
ArrayFilterEvent::CONVERSATION_START => 'conversation_start',
|
||||
ArrayFilterEvent::DISPLAY_ITEM => 'display_item',
|
||||
ArrayFilterEvent::RENDER_LOCATION => 'render_location',
|
||||
HtmlFilterEvent::HEAD => 'head',
|
||||
HtmlFilterEvent::FOOTER => 'footer',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'page_header',
|
||||
|
@ -79,6 +80,7 @@ final class HookEventBridge
|
|||
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DISPLAY_ITEM => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::RENDER_LOCATION => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
|
|
@ -38,6 +38,8 @@ final class ArrayFilterEvent extends Event
|
|||
|
||||
public const DISPLAY_ITEM = 'friendica.data.display_item';
|
||||
|
||||
public const RENDER_LOCATION = 'friendica.data.render_location';
|
||||
|
||||
private array $array;
|
||||
|
||||
public function __construct(string $name, array $array)
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace Friendica\Object;
|
|||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
@ -315,8 +314,14 @@ class Post
|
|||
$sparkle = ' sparkle';
|
||||
}
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
|
||||
Hook::callAll('render_location', $locate);
|
||||
|
||||
$locate = $eventDispatcher->dispatch(
|
||||
new ArrayFilterEvent(ArrayFilterEvent::RENDER_LOCATION, $locate),
|
||||
)->getArray();
|
||||
|
||||
$location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: '');
|
||||
|
||||
// process action responses - e.g. like/dislike/attend/agree/whatever
|
||||
|
@ -631,8 +636,6 @@ class Post
|
|||
],
|
||||
];
|
||||
|
||||
$eventDispatcher = DI::eventDispatcher();
|
||||
|
||||
$arr = ['item' => $item, 'output' => $tmp_item];
|
||||
|
||||
$arr = $eventDispatcher->dispatch(
|
||||
|
|
|
@ -39,6 +39,7 @@ class HookEventBridgeTest extends TestCase
|
|||
ArrayFilterEvent::NETWORK_TO_NAME => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::CONVERSATION_START => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::DISPLAY_ITEM => 'onArrayFilterEvent',
|
||||
ArrayFilterEvent::RENDER_LOCATION => 'onArrayFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_HEADER => 'onHtmlFilterEvent',
|
||||
|
@ -169,6 +170,7 @@ class HookEventBridgeTest extends TestCase
|
|||
[ArrayFilterEvent::NETWORK_TO_NAME, 'network_to_name'],
|
||||
[ArrayFilterEvent::CONVERSATION_START, 'conversation_start'],
|
||||
[ArrayFilterEvent::DISPLAY_ITEM, 'display_item'],
|
||||
[ArrayFilterEvent::RENDER_LOCATION, 'render_location'],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue