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\Core\Hook;
|
||||||
use Friendica\Event\DataFilterEvent;
|
use Friendica\Event\DataFilterEvent;
|
||||||
|
use Friendica\Event\HtmlFilterEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bridge between the EventDispatcher and the Hook class.
|
* Bridge between the EventDispatcher and the Hook class.
|
||||||
|
@ -24,6 +25,10 @@ final class HookEventBridge implements StaticEventSubscriber
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
DataFilterEvent::class => 'onDataFilterEvent',
|
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);
|
$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;
|
namespace Friendica\Test\Unit\EventSubscriber;
|
||||||
|
|
||||||
use Friendica\Event\DataFilterEvent;
|
use Friendica\Event\DataFilterEvent;
|
||||||
|
use Friendica\Event\HtmlFilterEvent;
|
||||||
use Friendica\EventSubscriber\HookEventBridge;
|
use Friendica\EventSubscriber\HookEventBridge;
|
||||||
use Friendica\EventSubscriber\StaticEventSubscriber;
|
use Friendica\EventSubscriber\StaticEventSubscriber;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
@ -28,6 +29,10 @@ class HookEventBridgeTest extends TestCase
|
||||||
{
|
{
|
||||||
$expected = [
|
$expected = [
|
||||||
DataFilterEvent::class => 'onDataFilterEvent',
|
DataFilterEvent::class => 'onDataFilterEvent',
|
||||||
|
HtmlFilterEvent::HEAD => 'onHtmlFilterEvent',
|
||||||
|
HtmlFilterEvent::FOOTER => 'onHtmlFilterEvent',
|
||||||
|
HtmlFilterEvent::PAGE_CONTENT_TOP => 'onHtmlFilterEvent',
|
||||||
|
HtmlFilterEvent::PAGE_END => 'onHtmlFilterEvent',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
|
@ -35,12 +40,15 @@ class HookEventBridgeTest extends TestCase
|
||||||
HookEventBridge::getStaticSubscribedEvents()
|
HookEventBridge::getStaticSubscribedEvents()
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($expected as $methodName) {
|
foreach (array_keys(array_flip($expected)) as $methodName) {
|
||||||
$this->assertTrue(method_exists(HookEventBridge::class, $methodName));
|
$this->assertTrue(
|
||||||
|
method_exists(HookEventBridge::class, $methodName),
|
||||||
|
$methodName . '() is not defined'
|
||||||
|
);
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
(new \ReflectionMethod(HookEventBridge::class, $methodName))->isStatic(),
|
(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