*/ declare(strict_types = 1); /** * Represents a possible type of internal processes in a museum. */ enum MDProcessType implements MDValueEnumInterface, JsonSerializable { 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 */ 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 */ 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 */ 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); } /** * Provides the option to serialize as a string during json_encode(). * * @return string */ public function jsonSerialize():string { return $this->name; } /** * Determines if there is a dedicated data type for the present process type in md. * * @return boolean */ public function hasOwnProcessType():bool { return match ($this) { self::exhibition => true, self::appointment => true, self::loan_incoming => true, self::loan_outgoing => true, default => false, }; } }