Add new enum for covering series contribution types for actors
This commit is contained in:
parent
4c1916247b
commit
6772476f9b
174
src/enums/MDSeriesContributorRole.php
Normal file
174
src/enums/MDSeriesContributorRole.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of contribution to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of contribution to an object group.
|
||||
*/
|
||||
enum MDSeriesContributorRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case author;
|
||||
case director;
|
||||
case dramaturg;
|
||||
case production_designer;
|
||||
case costumer;
|
||||
case musician;
|
||||
case choreographer;
|
||||
case make_up_artist;
|
||||
case speech_trainer;
|
||||
case puppet_maker;
|
||||
case technician;
|
||||
case inspector;
|
||||
case assistant;
|
||||
case actor;
|
||||
case painter;
|
||||
case creator;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesContributorRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesContributorRole {
|
||||
|
||||
return match($input) {
|
||||
"author" => self::author,
|
||||
"director" => self::director,
|
||||
"dramaturg" => self::dramaturg,
|
||||
"production_designer" => self::production_designer,
|
||||
"costumer" => self::costumer,
|
||||
"musician" => self::musician,
|
||||
"choreographer" => self::choreographer,
|
||||
"make_up_artist" => self::make_up_artist,
|
||||
"speech_trainer" => self::speech_trainer,
|
||||
"puppet_maker" => self::puppet_maker,
|
||||
"technician" => self::technician,
|
||||
"inspector" => self::inspector,
|
||||
"assistant" => self::assistant,
|
||||
"actor" => self::actor,
|
||||
"painter" => self::painter,
|
||||
"creator" => self::creator,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown attendance status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "attendance_status_set", "attendance_status_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "attendance_status_set", "attendance_status_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::author => 0,
|
||||
self::director => 1,
|
||||
self::dramaturg => 2,
|
||||
self::production_designer => 3,
|
||||
self::costumer => 4,
|
||||
self::musician => 5,
|
||||
self::choreographer => 6,
|
||||
self::make_up_artist => 7,
|
||||
self::speech_trainer => 8,
|
||||
self::puppet_maker => 9,
|
||||
self::technician => 10,
|
||||
self::inspector => 11,
|
||||
self::assistant => 12,
|
||||
self::actor => 13,
|
||||
self::painter => 14,
|
||||
self::creator => 15,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("attendance_status_set", "attendance_status_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user