Make MDCopyrightCollective implement MDValueEnumInterface

This commit is contained in:
2026-07-13 17:15:11 +02:00
parent a6394063c4
commit ce2f60d79d
+48 -1
View File
@@ -9,7 +9,7 @@ declare(strict_types = 1);
/** /**
* Represents a type of check an object may be subject to (completeness, condition, general audit). * Represents a type of check an object may be subject to (completeness, condition, general audit).
*/ */
enum MDCopyrightCollective implements JsonSerializable { enum MDCopyrightCollective implements MDValueEnumInterface, JsonSerializable {
case vg_bildkunst; case vg_bildkunst;
@@ -109,6 +109,53 @@ enum MDCopyrightCollective implements JsonSerializable {
} }
/**
* Returns the name of the current value in translation.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return string
*/
public function getTledName(MDTlLoader $tlLoader):string {
return match($this) {
self::vg_bildkunst => 'VG Bildkunst',
};
}
/**
* Gets an unsorted list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string, string>
*/
public static function getUnsortedList(MDTlLoader $tlLoader):array {
$output = [];
foreach (self::cases() as $case) {
$output[$case->name] = $case->getTledName($tlLoader);
};
return $output;
}
/**
* Gets a sorted list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string, string>
*/
public static function getSortedList(MDTlLoader $tlLoader):array {
$output = self::getUnsortedList($tlLoader);
asort($output);
return $output;
}
/** /**
* Provides the option to serialize as a string during json_encode(). * Provides the option to serialize as a string during json_encode().
* *