Add enum for process types in the museum
This commit is contained in:
parent
cc1a23c2fd
commit
42a02c186a
2
l18n
2
l18n
|
@ -1 +1 @@
|
|||
Subproject commit 9ee0ddd18008f086a62f001969863971e02f656e
|
||||
Subproject commit d2638c6f91395dc32c8b65ca68a3ae7bcac3b3e0
|
|
@ -35,7 +35,7 @@ final class MDProcessTypesSet extends MDValueSet {
|
|||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return parent::getTlSortedList($tlLoader, self::POSITIONS, "process_types", "process_types");
|
||||
return parent::getTlSortedList($tlLoader, self::TYPES, "process_types", "process_types");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
110
src/enums/MDProcessType.php
Normal file
110
src/enums/MDProcessType.php
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Represents a possible type of internal processes in a museum.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a possible type of internal processes in a museum.
|
||||
*/
|
||||
enum MDProcessType implements MDValueEnumInterface {
|
||||
|
||||
case project;
|
||||
case grant_application;
|
||||
case exhibition;
|
||||
case appointment; // This is MD's internally used name for events at the museum
|
||||
case loan_incoming;
|
||||
case loan_outgoing;
|
||||
case employment_ad;
|
||||
case purchase;
|
||||
case deaccession;
|
||||
case construction;
|
||||
case pest_control_campaign;
|
||||
case pr_campaign;
|
||||
case relocation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDProcessType
|
||||
*/
|
||||
public static function fromString(string $input):MDProcessType {
|
||||
|
||||
return match($input) {
|
||||
'project' => self::project,
|
||||
'grant_application' => self::grant_application,
|
||||
'exhibition' => self::exhibition,
|
||||
'appointment' => self::appointment,
|
||||
'loan_incoming' => self::loan_incoming,
|
||||
'loan_outgoing' => self::loan_outgoing,
|
||||
'employment_ad' => self::employment_ad,
|
||||
'purchase' => self::purchase,
|
||||
'deaccession' => self::deaccession,
|
||||
'construction' => self::construction,
|
||||
'pest_control_campaign' => self::pest_control_campaign,
|
||||
'pr_campaign' => self::pr_campaign,
|
||||
'relocation' => self::relocation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown process 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>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "process_types", "process_types");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "process_types", "process_types");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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("process_types", "process_types", $this->name);
|
||||
|
||||
}
|
||||
}
|
58
src/enums/MDValueEnumInterface.php
Normal file
58
src/enums/MDValueEnumInterface.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Describes an interface for a fully implemented enum describing a
|
||||
* list of controlled values at md. Expects the availabiliy of
|
||||
* translations for each.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Describes an interface for a fully implemented enum describing a
|
||||
* list of controlled values at md.
|
||||
*/
|
||||
interface MDValueEnumInterface {
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDValueEnumInterface
|
||||
*/
|
||||
public static function fromString(string $input):MDValueEnumInterface;
|
||||
|
||||
/**
|
||||
* Lists the case names available.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array;
|
||||
|
||||
/**
|
||||
* Gets an unsorted array based on provided keys and their translations.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array;
|
||||
|
||||
/**
|
||||
* Gets a list of entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array;
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string;
|
||||
}
|
Loading…
Reference in New Issue
Block a user