Add exception mode to redirect from object-tag relation type to
object-event relation (generic, e.g. if the tag is actually a time)
This commit is contained in:
9
exceptions/MDImporterTagRelationTypeIsEventType.php
Normal file
9
exceptions/MDImporterTagRelationTypeIsEventType.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case a name entered for the relation between tag
|
||||
* and object is actually an event type.
|
||||
*/
|
||||
final class MDImporterTagRelationTypeIsEventType extends Exception {
|
||||
}
|
@ -23,6 +23,8 @@ final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterfac
|
||||
'description' => 'tag',
|
||||
'emotion' => 'tag',
|
||||
'atmosphäre' => 'tag',
|
||||
'schlagwort hist.ereignis' => 'tag',
|
||||
'schlagwort thema' => 'tag',
|
||||
|
||||
"motive" => "display_subject",
|
||||
"motiv" => "display_subject",
|
||||
@ -36,6 +38,31 @@ final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterfac
|
||||
|
||||
];
|
||||
|
||||
// Maps to event type
|
||||
private const RELATION_TYPES_MAPPED_TO_EVENTS = [
|
||||
'\'datierung\'' => ['event_type' => 24, 'target_section' => 'time'],
|
||||
'datierung' => ['event_type' => 24, 'target_section' => 'time'],
|
||||
'schlagwort zeitraum' => ['event_type' => 24, 'target_section' => 'time'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns the mapped event type and event type target
|
||||
* of a supposed tag-object relationship name.
|
||||
*
|
||||
* @param string $input Input string (relation type name).
|
||||
*
|
||||
* @return array{event_type: int, target_section: 'time'|'actor'|'place'}
|
||||
*/
|
||||
public static function getMappedEventType(string $input):array {
|
||||
|
||||
if (isset(self::RELATION_TYPES_MAPPED_TO_EVENTS[strtolower($input)])) {
|
||||
return self::RELATION_TYPES_MAPPED_TO_EVENTS[strtolower($input)];
|
||||
}
|
||||
|
||||
throw new MDImporterMissingConcordance("Unknown object-tag relationship type: " . $input);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Require a function for getting the concordance target.
|
||||
*
|
||||
@ -52,6 +79,10 @@ final class MDConcObjectTagRelTypes implements MDImporterConcordanceListInterfac
|
||||
return self::RELATION_TYPE_NAMES[strtolower($input)];
|
||||
}
|
||||
|
||||
if (isset(self::RELATION_TYPES_MAPPED_TO_EVENTS[strtolower($input)])) {
|
||||
throw new MDImporterTagRelationTypeIsEventType("Tag-object relationship type is signifies not tags, but an event component.");
|
||||
}
|
||||
|
||||
throw new MDImporterMissingConcordance("Unknown object-tag relationship type: " . $input);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user