Enhance API with OIDC support, including login and callback endpoints. Update environment variables for OIDC configuration in .env.example. Add new features to the catalog service for listing software families, Minecraft versions, and deployment regions. Implement server management actions such as kill, delete, and update in the servers module. Integrate feature flags for maintenance mode in server operations. Update pnpm-lock.yaml with new dependencies and versions.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use WHMCS\Database\Capsule;
|
||||
|
||||
final class HexaGameCloudServiceMetadata
|
||||
{
|
||||
private const OPERATION_PREFIX = 'service:admin-meta:';
|
||||
|
||||
public static function load(string $serviceId): array
|
||||
{
|
||||
try {
|
||||
$row = Capsule::table('mod_hexagamecloud_operations')
|
||||
->where('operation', self::OPERATION_PREFIX . $serviceId)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if ($row === null || empty($row->metadata)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$decoded = json_decode((string) $row->metadata, true);
|
||||
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
} catch (Throwable) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public static function save(string $serviceId, array $data): void
|
||||
{
|
||||
$payload = json_encode($data, JSON_THROW_ON_ERROR);
|
||||
|
||||
try {
|
||||
$existing = Capsule::table('mod_hexagamecloud_operations')
|
||||
->where('operation', self::OPERATION_PREFIX . $serviceId)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
Capsule::table('mod_hexagamecloud_operations')
|
||||
->where('id', $existing->id)
|
||||
->update([
|
||||
'metadata' => $payload,
|
||||
'status' => 'saved',
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
Capsule::table('mod_hexagamecloud_operations')->insert([
|
||||
'operation' => self::OPERATION_PREFIX . $serviceId,
|
||||
'status' => 'saved',
|
||||
'metadata' => $payload,
|
||||
'created_at' => gmdate('Y-m-d H:i:s'),
|
||||
]);
|
||||
} catch (Throwable $exception) {
|
||||
logActivity('HexaGameCloud admin metadata save failed: ' . $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user