request->getHeader('User-Agent'); if (!$userAgent || !str_contains($userAgent, 'AscDesktopEditor')) { return; } $defaultAppId = $this->navigationManager->getDefaultEntryIdForUser(); if ($defaultAppId === 'files') { return; } $entry = $this->navigationManager->get($defaultAppId); if ($entry === null) { return; } $route = $this->request->getParam('_route'); if (!is_string($route) || $route === '') { return; } $routeParts = explode('.', $route); $currentAppId = $routeParts[0] === 'ocs' ? ($routeParts[1] ?? null) : ($routeParts[0] ?? null); if ($currentAppId === $defaultAppId) { throw new DesktopRedirectException(); } } public function afterException(Controller $controller, string $methodName, Exception $exception): Response { if ($exception instanceof DesktopRedirectException) { return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('files.view.index')); } throw $exception; } }