Centralize getSortedList in parent class
This commit is contained in:
parent
d4557c8cbd
commit
87e4cea8b1
@ -8,7 +8,7 @@
|
||||
/**
|
||||
* Class containing available units for events.
|
||||
*/
|
||||
class MDEventsSet {
|
||||
class MDEventsSet extends MDValueSet {
|
||||
|
||||
const EVENT_IDS = [
|
||||
'1', // => Created
|
||||
@ -57,14 +57,7 @@ class MDEventsSet {
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
|
||||
$output = [];
|
||||
foreach (self::EVENT_IDS as $tID) {
|
||||
$output[$tID] = $tlLoader->tl("eventtype_name", "eventname", $tID);
|
||||
}
|
||||
|
||||
asort($eventTypes);
|
||||
return $output;
|
||||
return parent::getSortedList($tlLoader, self::EVENT_IDS, "eventtype_name", "eventname");
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
/**
|
||||
* Class containing available marking types.
|
||||
*/
|
||||
class MDMarkingTypesSet {
|
||||
class MDMarkingTypesSet extends MDValueSet {
|
||||
|
||||
const MARKING_TYPES = [
|
||||
'signature',
|
||||
@ -21,4 +21,16 @@ class MDMarkingTypesSet {
|
||||
'handwritten',
|
||||
];
|
||||
|
||||
/**
|
||||
* 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 parent::getSortedList($tlLoader, self::MARKING_TYPES, "marking_types", "marking_types");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
35
src/MDValueSet.php
Normal file
35
src/MDValueSet.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Parent class for controlled lists of available values at md.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generic class for value sets.
|
||||
*/
|
||||
class MDValueSet {
|
||||
|
||||
/**
|
||||
* Gets a list of entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
* @param array<string> $keyList List of keys to get translations for.
|
||||
* @param string $tlFileName Name of the translation file.
|
||||
* @param string $tlVarName Variable of the translation.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader, array $keyList, string $tlFileName, string $tlVarName):array {
|
||||
|
||||
$output = [];
|
||||
foreach ($keyList as $tID) {
|
||||
$output[$tID] = $tlLoader->tl($tlFileName, $tlVarName, $tID);
|
||||
}
|
||||
|
||||
asort($output);
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user