Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG for 1.x
===================
## v1.15.0 - (2025-06-27)
### Added
- `ProcessStatusEnum` new methods based on the `EnumTrait` from the platform-core-bundle : getBgColor, getBgColors, getTextColors, getTextColor, labels

## v1.14.4 - (2025-06-24)
### Added
- `FileUtils::slugifyFilename` Slugify and normalize filename + tests
Expand Down
36 changes: 36 additions & 0 deletions src/Enum/ProcessStatusEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,40 @@ public static function casesByTrans(TranslatorInterface $translator, bool $onlyV

return $toReturn;
}

public static function getBgColor(mixed $case): ?string
{
return match ($case) {
self::ONGOING => '#3b82f6', // info-color colors.blue.500
self::SUCCESS => '#22c55e', // success-color colors.green.500
self::ERROR => '#dc2626', // danger-color colors.red.600
default => null,
};
}

public static function getBgColors(): array
{
return array_map(function (self $case) {
return self::getBgColor($case);
}, self::cases());
}

public static function getTextColors(): array
{
return array_map(function (self $case) {
return self::getTextColor($case);
}, self::cases());
}

public static function getTextColor(mixed $case): ?string
{
return '#ffffff';
}

public static function labels(TranslatorInterface $translator): array
{
return array_map(function (self $case) use ($translator) {
return $translator->trans(self::PREFIX_LABEL . $case->value, [], 'enum');
}, self::cases());
}
}