added event to manage javascript translations (#2104)

This commit is contained in:
Kevin Papst
2020-11-09 13:28:22 +01:00
committed by GitHub
parent 66865b553e
commit bd4efad22b
7 changed files with 127 additions and 25 deletions

View File

@@ -22,6 +22,7 @@ class EventExtensions extends AbstractExtension
{
return [
new TwigFunction('trigger', [ThemeEventExtension::class, 'trigger']),
new TwigFunction('javascript_translations', [ThemeEventExtension::class, 'getJavascriptTranslations']),
];
}
}

View File

@@ -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();
}
}