mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 10:05:43 +02:00
Add support for HtmlFilterEvent in HookEventBridge
This commit is contained in:
parent
599ea41095
commit
00ff02da45
2 changed files with 25 additions and 3 deletions
|
@ -11,6 +11,7 @@ namespace Friendica\EventSubscriber;
|
|||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Event\DataFilterEvent;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
|
||||
/**
|
||||
* Bridge between the EventDispatcher and the Hook class.
|
||||
|
@ -24,6 +25,10 @@ final class HookEventBridge implements StaticEventSubscriber
|
|||
{
|
||||
return [
|
||||
DataFilterEvent::class => 'onDataFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -35,4 +40,13 @@ final class HookEventBridge implements StaticEventSubscriber
|
|||
|
||||
$event->setData($data);
|
||||
}
|
||||
|
||||
public static function onHtmlFilterEvent(HtmlFilterEvent $event): void
|
||||
{
|
||||
$html = $event->getHtml();
|
||||
|
||||
// Hook::callAll($event->getName(), $html);
|
||||
|
||||
$event->setHtml($html);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
namespace Friendica\Test\Unit\EventSubscriber;
|
||||
|
||||
use Friendica\Event\DataFilterEvent;
|
||||
use Friendica\Event\HtmlFilterEvent;
|
||||
use Friendica\EventSubscriber\HookEventBridge;
|
||||
use Friendica\EventSubscriber\StaticEventSubscriber;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
@ -28,6 +29,10 @@ class HookEventBridgeTest extends TestCase
|
|||
{
|
||||
$expected = [
|
||||
DataFilterEvent::class => 'onDataFilterEvent',
|
||||
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
|
||||
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
|
||||
];
|
||||
|
||||
$this->assertSame(
|
||||
|
@ -35,12 +40,15 @@ class HookEventBridgeTest extends TestCase
|
|||
HookEventBridge::getStaticSubscribedEvents()
|
||||
);
|
||||
|
||||
foreach ($expected as $methodName) {
|
||||
$this->assertTrue(method_exists(HookEventBridge::class, $methodName));
|
||||
foreach (array_keys(array_flip($expected)) as $methodName) {
|
||||
$this->assertTrue(
|
||||
method_exists(HookEventBridge::class, $methodName),
|
||||
$methodName . '() is not defined'
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
(new \ReflectionMethod(HookEventBridge::class, $methodName))->isStatic(),
|
||||
$methodName . ' is not static'
|
||||
$methodName . '() is not static'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue