]> git.mxchange.org Git - friendica.git/commitdiff
create event for smilie hook
authorArt4 <art4@wlabs.de>
Fri, 14 Feb 2025 13:00:21 +0000 (13:00 +0000)
committerArt4 <art4@wlabs.de>
Fri, 14 Feb 2025 13:00:21 +0000 (13:00 +0000)
src/Content/Smilies.php
src/Core/Hooks/HookEventBridge.php
src/Event/ArrayFilterEvent.php
tests/Unit/Core/Hooks/HookEventBridgeTest.php
tests/Unit/Event/ArrayFilterEventTest.php

index f6b69065d732e35d55b09f4742c0eba1820d1f05..bce403a3715c9061dbff98d977d559d0107d5f9f 100644 (file)
@@ -8,8 +8,8 @@
 namespace Friendica\Content;
 
 use Friendica\Content\Text\BBCode;
-use Friendica\Core\Hook;
 use Friendica\DI;
+use Friendica\Event\ArrayFilterEvent;
 use Friendica\Util\Strings;
 
 /**
@@ -133,8 +133,13 @@ class Smilies
                '<a href="http://redmatrix.me/">red<img class="smiley" src="' . $baseUrl . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
                ];
 
+               $eventDispatcher = DI::eventDispatcher();
+
                $params = ['texts' => $texts, 'icons' => $icons];
-               Hook::callAll('smilie', $params);
+
+               $params = $eventDispatcher->dispatch(
+                       new ArrayFilterEvent(ArrayFilterEvent::SMILEY_LIST, $params),
+               )->getArray();
 
                return $params;
        }
index 1479e41d541d58c3d56024496823949fc765963e..ec79484f287bc1682b2dbe91264456fd6aaf6e51 100644 (file)
@@ -54,6 +54,7 @@ final class HookEventBridge
                ArrayFilterEvent::ITEM_PHOTO_MENU    => 'item_photo_menu',
                ArrayFilterEvent::OEMBED_FETCH_END   => 'oembed_fetch_url',
                ArrayFilterEvent::PAGE_INFO          => 'page_info_data',
+               ArrayFilterEvent::SMILEY_LIST        => 'smilie',
                HtmlFilterEvent::HEAD                => 'head',
                HtmlFilterEvent::FOOTER              => 'footer',
                HtmlFilterEvent::PAGE_HEADER         => 'page_header',
@@ -87,6 +88,7 @@ final class HookEventBridge
                        ArrayFilterEvent::ITEM_PHOTO_MENU    => 'onArrayFilterEvent',
                        ArrayFilterEvent::OEMBED_FETCH_END   => 'onOembedFetchEndEvent',
                        ArrayFilterEvent::PAGE_INFO          => 'onArrayFilterEvent',
+                       ArrayFilterEvent::SMILEY_LIST        => 'onArrayFilterEvent',
                        HtmlFilterEvent::HEAD                => 'onHtmlFilterEvent',
                        HtmlFilterEvent::FOOTER              => 'onHtmlFilterEvent',
                        HtmlFilterEvent::PAGE_HEADER         => 'onHtmlFilterEvent',
index 41158c7eb3fff10d682ebd3ad81857b4f97f964e..d5f9b4e96d5c2db9ddb9f14cd5a219747185f56a 100644 (file)
@@ -46,6 +46,8 @@ final class ArrayFilterEvent extends Event
 
        public const PAGE_INFO = 'friendica.data.page_info';
 
+       public const SMILEY_LIST = 'friendica.data.smiley_list';
+
        private array $array;
 
        public function __construct(string $name, array $array)
index d6d7801f132449e9476ff02587536916520ef6a7..58c9e2985302e30a9067d1487d7bf281870215c6 100644 (file)
@@ -43,6 +43,7 @@ class HookEventBridgeTest extends TestCase
                        ArrayFilterEvent::ITEM_PHOTO_MENU    => 'onArrayFilterEvent',
                        ArrayFilterEvent::OEMBED_FETCH_END   => 'onOembedFetchEndEvent',
                        ArrayFilterEvent::PAGE_INFO          => 'onArrayFilterEvent',
+                       ArrayFilterEvent::SMILEY_LIST        => 'onArrayFilterEvent',
                        HtmlFilterEvent::HEAD                => 'onHtmlFilterEvent',
                        HtmlFilterEvent::FOOTER              => 'onHtmlFilterEvent',
                        HtmlFilterEvent::PAGE_HEADER         => 'onHtmlFilterEvent',
@@ -198,6 +199,7 @@ class HookEventBridgeTest extends TestCase
                        [ArrayFilterEvent::RENDER_LOCATION, 'render_location'],
                        [ArrayFilterEvent::ITEM_PHOTO_MENU, 'item_photo_menu'],
                        [ArrayFilterEvent::PAGE_INFO, 'page_info_data'],
+                       [ArrayFilterEvent::SMILEY_LIST, 'smilie'],
                ];
        }
 
index 00e47f4b61ebe5085ce6d9221cd7592d52b57c1c..2fa8f786631e5c2fbed8a8a35ba2bae1e3929092 100644 (file)
@@ -40,6 +40,7 @@ class ArrayFilterEventTest extends TestCase
                        [ArrayFilterEvent::ITEM_PHOTO_MENU, 'friendica.data.item_photo_menu'],
                        [ArrayFilterEvent::OEMBED_FETCH_END, 'friendica.data.oembed_fetch_end'],
                        [ArrayFilterEvent::PAGE_INFO, 'friendica.data.page_info'],
+                       [ArrayFilterEvent::SMILEY_LIST, 'friendica.data.smiley_list'],
                ];
        }