query->get('q', '')); if (mb_strlen($query) < self::MIN_QUERY_LENGTH) { return new JsonResponse(['query' => $query, 'entries' => []]); } try { $entries = $this->fileSource->search($query); } catch (ShareNotConfiguredException) { return new JsonResponse(['error' => 'Share not configured.'], 409); } catch (ShareConnectionException) { return new JsonResponse(['error' => 'Unable to reach the file share.'], 502); } return new JsonResponse([ 'query' => $query, 'entries' => array_map(static fn (FileEntry $e): array => [ 'name' => $e->name, 'path' => $e->path, 'isDir' => $e->isDir, 'size' => $e->size, 'modifiedAt' => $e->modifiedAt, 'mimeType' => $e->mimeType, ], $entries), ]); } }