-
Notifications
You must be signed in to change notification settings - Fork 1
/
listener.php
40 lines (34 loc) · 1 KB
/
listener.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* @package s9e\noto-emoji
* @copyright Copyright (c) 2017-2018 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\notoemoji;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class listener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return ['core.text_formatter_s9e_configure_after' => 'onConfigure'];
}
public function onConfigure($event)
{
if (!isset($event['configurator']->tags['EMOJI']))
{
return;
}
$tag = $event['configurator']->tags['EMOJI'];
$dom = $tag->template->asDOM();
foreach ($dom->getElementsByTagName('img') as $img)
{
$img->setAttribute('src', 'https://cdn.jsdelivr.net/gh/s9e/emoji-assets/assets/noto/svgz/{@seq}.svgz');
$firstChild = $img->firstChild;
if ($firstChild && $firstChild->nodeName === 'xsl:attribute' && $firstChild->getAttribute('name') === 'src')
{
$img->removeChild($firstChild);
}
}
$dom->saveChanges();
}
}