diff --git a/src/MDEventsSet.php b/src/MDEventsSet.php index 2065999..c872ff3 100644 --- a/src/MDEventsSet.php +++ b/src/MDEventsSet.php @@ -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 */ 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"); } diff --git a/src/MDMarkingTypesSet.php b/src/MDMarkingTypesSet.php index 8c5abf2..1310802 100644 --- a/src/MDMarkingTypesSet.php +++ b/src/MDMarkingTypesSet.php @@ -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 + */ + public static function getSortedList(MDTlLoader $tlLoader):array { + return parent::getSortedList($tlLoader, self::MARKING_TYPES, "marking_types", "marking_types"); + + } + } diff --git a/src/MDValueSet.php b/src/MDValueSet.php new file mode 100644 index 0000000..9961ae5 --- /dev/null +++ b/src/MDValueSet.php @@ -0,0 +1,35 @@ + + */ + +/** + * Generic class for value sets. + */ +class MDValueSet { + + /** + * Gets a list of entries in a translated version. + * + * @param MDTlLoader $tlLoader Translation loader. + * @param array $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 + */ + 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; + + } + +}