From df755d521c0d5a3b4c8d78b05940db2aee7c6957 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Wed, 8 Apr 2026 16:04:03 +0200 Subject: [PATCH] feat : add DatabaseInfo API resource and provider Co-Authored-By: Claude Sonnet 4.6 --- src/ApiResource/DatabaseInfo.php | 29 ++++++++++++++++++ src/State/DatabaseInfoProvider.php | 49 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 src/ApiResource/DatabaseInfo.php create mode 100644 src/State/DatabaseInfoProvider.php diff --git a/src/ApiResource/DatabaseInfo.php b/src/ApiResource/DatabaseInfo.php new file mode 100644 index 0000000..3299db9 --- /dev/null +++ b/src/ApiResource/DatabaseInfo.php @@ -0,0 +1,29 @@ +environmentRepository->find($id) : null; + + if (null === $environment) { + throw new NotFoundHttpException(sprintf('Environment "%s" not found.', $id)); + } + + $databaseName = $environment->getDatabaseName(); + + if (null === $databaseName || '' === $databaseName) { + throw new NotFoundHttpException('No database configured for this environment.'); + } + + $info = $this->databaseService->getDatabaseInfo($databaseName); + + $dto = new DatabaseInfo(); + $dto->connected = $info['connected']; + $dto->name = $info['name']; + $dto->size = $info['size']; + $dto->tableCount = $info['tableCount']; + $dto->activeConnections = $info['activeConnections']; + $dto->cacheHitRatio = $info['cacheHitRatio']; + $dto->largestTable = $info['largestTable']; + + return $dto; + } +}