enum fix, create form wip
This commit is contained in:
@@ -69,6 +69,14 @@ class GenerateJSEnums extends Command
|
||||
$js .= "\n";
|
||||
}
|
||||
|
||||
if (method_exists($enum, 'getDescription')) {
|
||||
$values = $enum::toArray();
|
||||
$descriptions = array_map(fn($key) => $enum::getDescription($key), $values);
|
||||
$js .= 'export const DescriptionMap = ';
|
||||
$js .= json_encode($descriptions, JSON_PRETTY_PRINT) . "\n";
|
||||
$js .= "\n";
|
||||
}
|
||||
|
||||
if (method_exists($enum, 'colours')) {
|
||||
$colours = $enum::colours();
|
||||
$js .= 'export const ColourMap = ';
|
||||
|
||||
@@ -13,4 +13,20 @@ enum ServiceCategory: string
|
||||
case GATEWAY = 'gateway';
|
||||
case STORAGE = 'storage';
|
||||
case CACHE = 'cache';
|
||||
|
||||
public static function getDescription(ServiceCategory|string $category) {
|
||||
if (is_string($category)) {
|
||||
$category = ServiceCategory::from($category);
|
||||
}
|
||||
if (! $category instanceof ServiceCategory) {
|
||||
throw new \InvalidArgumentException('Invalid category provided');
|
||||
}
|
||||
return match ($category) {
|
||||
self::APPLICATION => 'The base container image for your application',
|
||||
self::DATABASE => 'Postgres or MySQL',
|
||||
self::GATEWAY => 'The gateway is the first point of contact for your application',
|
||||
self::STORAGE => 'S3 or S3-compatible service',
|
||||
self::CACHE => 'Redis, Memcached or similar',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user