added event to manage javascript translations (#2104)
This commit is contained in:
@@ -22,6 +22,7 @@ class EventExtensions extends AbstractExtension
|
||||
{
|
||||
return [
|
||||
new TwigFunction('trigger', [ThemeEventExtension::class, 'trigger']),
|
||||
new TwigFunction('javascript_translations', [ThemeEventExtension::class, 'getJavascriptTranslations']),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
namespace App\Twig\Runtime;
|
||||
|
||||
use App\Event\ThemeEvent;
|
||||
use App\Event\ThemeJavascriptTranslationsEvent;
|
||||
use App\Security\CurrentUser;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
@@ -46,4 +47,13 @@ final class ThemeEventExtension implements RuntimeExtensionInterface
|
||||
|
||||
return $themeEvent;
|
||||
}
|
||||
|
||||
public function getJavascriptTranslations(): array
|
||||
{
|
||||
$event = new ThemeJavascriptTranslationsEvent();
|
||||
|
||||
$this->eventDispatcher->dispatch($event);
|
||||
|
||||
return $event->getTranslations();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user