Skip to content

Commit

Permalink
Add mirador display hint to book and issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordandukart committed Nov 25, 2024
1 parent 8915321 commit 44e13ca
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Plugin/dgi_migrate_alter/foxml/DgisNodesAlter.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ public function alter(array &$migration) {
['_rights_statement', 7],
];

$this->addMiradorDisplayHints($process);

foreach ($to_remove as $path) {
NestedArray::unsetValue($process, $path);
}
Expand Down Expand Up @@ -401,4 +403,38 @@ private function processStatusCheck(array &$process): void {
];
}

/**
* Add Mirador display hints.
*
* @param array $process
* The process array to alter.
*/
protected function addMiradorDisplayHints(&$process) {
$display_hints = &$process['field_display_hints'];
$mirador_hints = [
'https://schema.org/Book' => 'https://projectmirador.org',
'https://schema.org/PublicationIssue' => 'https://projectmirador.org',
];
$existence = [
'https://schema.org/Book' => FALSE,
'https://schema.org/PublicationIssue' => FALSE,
];

// Only add hints if they already don't exist.
foreach ($display_hints[0]['map'] as $display_hint) {
$model = $display_hint[0];
if (isset($mirador_hints[$model])) {
$existence[$model] = TRUE;
}
}

array_filter($existence);
foreach (array_keys($existence) as $mirador_hint) {
$display_hints[0]['map'][] = [
$mirador_hint,
[$mirador_hints[$mirador_hint]],
];
}
}

}

0 comments on commit 44e13ca

Please sign in to comment.