Add controlled lists for recording types and accepted hosters
This commit is contained in:
+1
-1
Submodule l18n updated: 963412a4d2...38eb44046b
@@ -0,0 +1,104 @@
|
|||||||
|
<?PHP
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an allowed hoster for videos of events.
|
||||||
|
*/
|
||||||
|
enum MDAppointmentRecordingHoster implements MDValueEnumInterface, JsonSerializable {
|
||||||
|
|
||||||
|
case archive_org;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a string.
|
||||||
|
*
|
||||||
|
* @param string $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDAppointmentRecordingHoster
|
||||||
|
*/
|
||||||
|
public static function fromString(string $input):MDAppointmentRecordingHoster {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
'archive_org' => self::archive_org,
|
||||||
|
'Archive.org' => self::archive_org,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown hoster"),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function toString():string {
|
||||||
|
return match(this) {
|
||||||
|
self::archive_org => 'Archive.org',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all available names.
|
||||||
|
*
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function caseNames():array {
|
||||||
|
|
||||||
|
$output = [];
|
||||||
|
|
||||||
|
$cases = self::cases();
|
||||||
|
foreach ($cases as $case) {
|
||||||
|
$output[] = $case->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
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(), "appointment_recording_hoster", "appointment_recording_hoster");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(), "appointment_recording_hoster", "appointment_recording_hoster");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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("appointment_recording_hoster", "appointment_recording_hoster", $this->toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the option to serialize as a string during json_encode().
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonSerialize():string {
|
||||||
|
|
||||||
|
return $this->toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
<?PHP
|
||||||
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an allowed type of recording for events / appointments.
|
||||||
|
*/
|
||||||
|
enum MDAppointmentRecordingType implements MDValueEnumInterface, JsonSerializable {
|
||||||
|
|
||||||
|
case video;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value of this type based on a string.
|
||||||
|
*
|
||||||
|
* @param string $input Input to get a value from.
|
||||||
|
*
|
||||||
|
* @return MDAppointmentRecordingType
|
||||||
|
*/
|
||||||
|
public static function fromString(string $input):MDAppointmentRecordingType {
|
||||||
|
|
||||||
|
return match($input) {
|
||||||
|
'video' => self::video,
|
||||||
|
default => throw new MDpageParameterNotFromListException("Unknown appointment recording 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(), "appointment_recording_types", "appointment_recording_types");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(), "appointment_recording_types", "appointment_recording_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("appointment_recording_types", "appointment_recording_types", $this->name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the option to serialize as a string during json_encode().
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function jsonSerialize():string {
|
||||||
|
|
||||||
|
return $this->name;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user