Add new enums for object document type, institution categorization
Close #24, close #25, close #26, close #27
This commit is contained in:
parent
493ef9f721
commit
d68c114905
2
l18n
2
l18n
|
@ -1 +1 @@
|
|||
Subproject commit 90e20227f72b4e22ec2b3ed1d6037d8384ab5ca6
|
||||
Subproject commit eff355e85c9519f28eb2ad6a10c3bd1e835bd188
|
161
src/enums/MDInstitutionBasicCategory.php
Normal file
161
src/enums/MDInstitutionBasicCategory.php
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents a most basic categorization of institutions using museum-digital.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a most basic categorization of institutions using museum-digital.
|
||||
*/
|
||||
enum MDInstitutionBasicCategory implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case museum;
|
||||
case archive;
|
||||
case library;
|
||||
case memorial_site;
|
||||
case private_collection;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionBasicCategory
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionBasicCategory {
|
||||
|
||||
return match($input) {
|
||||
"museum" => self::museum,
|
||||
"archive" => self::archive,
|
||||
"library" => self::library,
|
||||
"memorial_site" => self::memorial_site,
|
||||
"private_collection" => self::private_collection,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown institution category"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionBasicCategory
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionBasicCategory {
|
||||
|
||||
return match($input) {
|
||||
0 => self::museum,
|
||||
1 => self::archive,
|
||||
2 => self::library,
|
||||
3 => self::memorial_site,
|
||||
4 => self::private_collection,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown institution category"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(), "institution_basic_category_set", "institution_basic_category_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(), "institution_basic_category_set", "institution_basic_category_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::museum => 0,
|
||||
self::archive => 1,
|
||||
self::library => 2,
|
||||
self::memorial_site => 3,
|
||||
self::private_collection => 4,
|
||||
# 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("institution_basic_category_set", "institution_basic_category_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
237
src/enums/MDInstitutionCollectionArea.php
Normal file
237
src/enums/MDInstitutionCollectionArea.php
Normal file
|
@ -0,0 +1,237 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents a type of collection focus a museum (or similar institution) may have.
|
||||
* This can be useful for statistics and be used in line with institutions' self-
|
||||
* categorization.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of collection focus a museum (or similar institution) may have.
|
||||
* This can be useful for statistics and be used in line with institutions' self-
|
||||
* categorization.
|
||||
*/
|
||||
enum MDInstitutionCollectionArea implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case everyday_life;
|
||||
case archaeology;
|
||||
case architecture;
|
||||
case history_of_mining;
|
||||
case botany;
|
||||
case history_of_film;
|
||||
case political_history;
|
||||
case arts;
|
||||
case applied_arts;
|
||||
case agriculture;
|
||||
case literature;
|
||||
case history_of_medicine;
|
||||
case military_history;
|
||||
case mineralogy;
|
||||
case music;
|
||||
case numismatics;
|
||||
case paleontology;
|
||||
case personalia;
|
||||
case regional_history;
|
||||
case religion;
|
||||
case technology;
|
||||
case ethnography;
|
||||
case zoology;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionCollectionArea
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionCollectionArea {
|
||||
|
||||
return match($input) {
|
||||
"everyday_life" => self::everyday_life,
|
||||
"archaeology" => self::archaeology,
|
||||
"architecture" => self::architecture,
|
||||
"history_of_mining" => self::history_of_mining,
|
||||
"botany" => self::botany,
|
||||
"history_of_film" => self::history_of_film,
|
||||
"political_history" => self::political_history,
|
||||
"arts" => self::arts,
|
||||
"applied_arts" => self::applied_arts,
|
||||
"agriculture" => self::agriculture,
|
||||
"literature" => self::literature,
|
||||
"history_of_medicine" => self::history_of_medicine,
|
||||
"military_history" => self::military_history,
|
||||
"mineralogy" => self::mineralogy,
|
||||
"music" => self::music,
|
||||
"numismatics" => self::numismatics,
|
||||
"paleontology" => self::paleontology,
|
||||
"personalia" => self::personalia,
|
||||
"regional_history" => self::regional_history,
|
||||
"religion" => self::religion,
|
||||
"technology" => self::technology,
|
||||
"ethnography" => self::ethnography,
|
||||
"zoology" => self::zoology,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown collection focus area"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionCollectionArea
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionCollectionArea {
|
||||
|
||||
return match($input) {
|
||||
0 => self::everyday_life,
|
||||
1 => self::archaeology,
|
||||
2 => self::architecture,
|
||||
3 => self::history_of_mining,
|
||||
4 => self::botany,
|
||||
5 => self::history_of_film,
|
||||
6 => self::political_history,
|
||||
7 => self::arts,
|
||||
8 => self::applied_arts,
|
||||
9 => self::agriculture,
|
||||
10 => self::literature,
|
||||
11 => self::history_of_medicine,
|
||||
12 => self::military_history,
|
||||
13 => self::mineralogy,
|
||||
14 => self::music,
|
||||
15 => self::numismatics,
|
||||
16 => self::paleontology,
|
||||
17 => self::personalia,
|
||||
18 => self::regional_history,
|
||||
19 => self::religion,
|
||||
20 => self::technology,
|
||||
21 => self::ethnography,
|
||||
22 => self::zoology,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown collection focus area"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(), "institution_collection_area_set", "institution_collection_area_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(), "institution_collection_area_set", "institution_collection_area_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::everyday_life => 0,
|
||||
self::archaeology => 1,
|
||||
self::architecture => 2,
|
||||
self::history_of_mining => 3,
|
||||
self::botany => 4,
|
||||
self::history_of_film => 5,
|
||||
self::political_history => 6,
|
||||
self::arts => 7,
|
||||
self::applied_arts => 8,
|
||||
self::agriculture => 9,
|
||||
self::literature => 10,
|
||||
self::history_of_medicine => 11,
|
||||
self::military_history => 12,
|
||||
self::mineralogy => 13,
|
||||
self::music => 14,
|
||||
self::numismatics => 15,
|
||||
self::paleontology => 16,
|
||||
self::personalia => 17,
|
||||
self::regional_history => 18,
|
||||
self::religion => 19,
|
||||
self::technology => 20,
|
||||
self::ethnography => 21,
|
||||
self::zoology => 22,
|
||||
# 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("institution_collection_area_set", "institution_collection_area_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
157
src/enums/MDInstitutionPublicPrivateStatus.php
Normal file
157
src/enums/MDInstitutionPublicPrivateStatus.php
Normal file
|
@ -0,0 +1,157 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents the status of an institution as a public or privately-run one.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents the status of an institution as a public or privately-run one.
|
||||
*/
|
||||
enum MDInstitutionPublicPrivateStatus implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case public;
|
||||
case private;
|
||||
case religious;
|
||||
case mixed;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionPublicPrivateStatus
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionPublicPrivateStatus {
|
||||
|
||||
return match($input) {
|
||||
"public" => self::public,
|
||||
"private" => self::private,
|
||||
"religious" => self::religious,
|
||||
"mixed" => self::mixed,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown public / private status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionPublicPrivateStatus
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionPublicPrivateStatus {
|
||||
|
||||
return match($input) {
|
||||
0 => self::public,
|
||||
1 => self::private,
|
||||
2 => self::religious,
|
||||
3 => self::mixed,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown public / private 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(), "institution_public_private_category_set", "institution_public_private_category_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(), "institution_public_private_category_set", "institution_public_private_category_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::public => 0,
|
||||
self::private => 1,
|
||||
self::religious => 2,
|
||||
self::mixed => 3,
|
||||
# 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("institution_public_private_category_set", "institution_public_private_category_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
153
src/enums/MDInstitutionUseCase.php
Normal file
153
src/enums/MDInstitutionUseCase.php
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents the use case an institution uses museum-digital's tools for.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents the use case an institution uses museum-digital's tools for.
|
||||
*/
|
||||
enum MDInstitutionUseCase implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case collection_management;
|
||||
case publication;
|
||||
case collection_management_and_publication;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionUseCase
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionUseCase {
|
||||
|
||||
return match($input) {
|
||||
"collection_management" => self::collection_management,
|
||||
"publication" => self::publication,
|
||||
"collection_management_and_publication" => self::collection_management_and_publication,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionUseCase
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionUseCase {
|
||||
|
||||
return match($input) {
|
||||
0 => self::collection_management,
|
||||
1 => self::publication,
|
||||
2 => self::collection_management_and_publication,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(), "institution_musdb_use_case_set", "institution_musdb_use_case_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(), "institution_musdb_use_case_set", "institution_musdb_use_case_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::collection_management => 0,
|
||||
self::publication => 1,
|
||||
self::collection_management_and_publication => 2,
|
||||
# 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("institution_musdb_use_case_set", "institution_musdb_use_case_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
169
src/enums/MDObjectDocumentType.php
Normal file
169
src/enums/MDObjectDocumentType.php
Normal file
|
@ -0,0 +1,169 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents a type of document published alongside an object.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of document published alongside an object.
|
||||
*/
|
||||
enum MDObjectDocumentType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case undefined;
|
||||
case provenance_report;
|
||||
case purchase_contract;
|
||||
case restoration_report;
|
||||
case assessment;
|
||||
case correspondence;
|
||||
case legacy_documentation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectDocumentType
|
||||
*/
|
||||
public static function fromString(string $input):MDObjectDocumentType {
|
||||
|
||||
return match($input) {
|
||||
"undefined" => self::undefined,
|
||||
"provenance_report" => self::provenance_report,
|
||||
"purchase_contract" => self::purchase_contract,
|
||||
"restoration_report" => self::restoration_report,
|
||||
"assessment" => self::assessment,
|
||||
"correspondence" => self::correspondence,
|
||||
"legacy_documentation" => self::legacy_documentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown document type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectDocumentType
|
||||
*/
|
||||
public static function fromInt(int $input):MDObjectDocumentType {
|
||||
|
||||
return match($input) {
|
||||
0 => self::undefined,
|
||||
1 => self::provenance_report,
|
||||
2 => self::purchase_contract,
|
||||
3 => self::restoration_report,
|
||||
4 => self::assessment,
|
||||
5 => self::correspondence,
|
||||
6 => self::legacy_documentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown document type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(), "object_document_type_set", "object_document_type_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(), "object_document_type_set", "object_document_type_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::undefined => 0,
|
||||
self::provenance_report => 1,
|
||||
self::purchase_contract => 2,
|
||||
self::restoration_report => 3,
|
||||
self::assessment => 4,
|
||||
self::correspondence => 5,
|
||||
self::legacy_documentation => 6,
|
||||
# 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("object_document_type_set", "object_document_type_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
|
@ -54,7 +54,7 @@ enum MDSeriesContributorRole implements MDValueEnumInterface, JsonSerializable {
|
|||
"actor" => self::actor,
|
||||
"painter" => self::painter,
|
||||
"creator" => self::creator,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown attendance status"),
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ enum MDSeriesContributorRole implements MDValueEnumInterface, JsonSerializable {
|
|||
13 => self::actor,
|
||||
14 => self::painter,
|
||||
15 => self::creator,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown attendance status"),
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user