*/ class LoadViewerListener implements IEventListener { public function __construct( private PermissionManager $permissionManager, private InitialStateService $initialStateService, private IEventDispatcher $eventDispatcher, private ?string $userId, ) { } #[\Override] public function handle(Event $event): void { if (!$event instanceof LoadViewer) { return; } if ($this->permissionManager->isEnabledForUser() && $this->userId !== null) { $this->initialStateService->provideCapabilities(); Util::addInitScript(Application::APPNAME, Application::APPNAME . '-init-viewer'); Util::addScript(Application::APPNAME, Application::APPNAME . '-viewer', 'viewer'); $this->eventDispatcher->dispatchTyped(new RenderReferenceEvent()); } } }