feat: theming
All checks were successful
JS Unit Tests / test (pull_request) Successful in 17s
Build Test / build (pull_request) Successful in 19s
PHP Unit Tests / test (pull_request) Successful in 54s

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-02-22 21:25:26 -05:00
parent 6975800ce5
commit b68ac538ce
7 changed files with 331 additions and 45 deletions

View File

@@ -72,4 +72,57 @@ class TenantStore
$this->dataStore->selectCollection(self::COLLECTION_NAME)->deleteOne([ '_id' => $id]);
}
// =========================================================================
// Settings Operations
// =========================================================================
/**
* Fetch settings for a tenant, optionally filtered to specific keys.
*
* @param string $identifier Tenant identifier
* @param string[] $keys Optional list of keys to return; empty = all
*
* @return array<string, mixed>
*/
public function fetchSettings(string $identifier, array $keys = []): array
{
$entry = $this->dataStore->selectCollection(self::COLLECTION_NAME)->findOne(
['identifier' => $identifier],
['projection' => ['settings' => 1]]
);
$settings = (array)($entry['settings'] ?? []);
if (empty($keys)) {
return $settings;
}
$result = [];
foreach ($keys as $key) {
$result[$key] = $settings[$key] ?? null;
}
return $result;
}
/**
* Merge-update settings for a tenant using atomic $set on sub-fields.
*
* @param string $identifier Tenant identifier
* @param array<string, mixed> $settings Key-value pairs to persist
*/
public function storeSettings(string $identifier, array $settings): bool
{
$updates = [];
foreach ($settings as $key => $value) {
$updates["settings.{$key}"] = $value;
}
$result = $this->dataStore->selectCollection(self::COLLECTION_NAME)->updateOne(
['identifier' => $identifier],
['$set' => $updates]
);
return $result->getMatchedCount() > 0;
}
}