Skip to content

Commit

Permalink
Shortcircuiting if search_endpoint isn't set (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchiasson-dgi authored Jul 7, 2024
1 parent 14c4e42 commit 60a1678
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,20 @@ protected function defineOptions() {
*/
protected function addSearchEndpoint(array &$json, array $url_components) {
$url_base = $this->getRequest()->getSchemeAndHttpHost();
$hocr_search_path = $this->options['search_endpoint'];
$hocr_search_url = $url_base . '/' . ltrim($hocr_search_path, '/');
$hocr_search_path = $this->options['search_endpoint'] ?? null;

$hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url);
if ($hocr_search_path) {
$hocr_search_url = $url_base . '/' . ltrim($hocr_search_path, '/');

$json['service'][] = [
"@context" => "http://iiif.io/api/search/0/context.json",
"@id" => $hocr_search_url,
"profile" => "http://iiif.io/api/search/0/search",
"label" => t("Search inside this work"),
];
$hocr_search_url = str_replace('%node', $url_components[1], $hocr_search_url);

$json['service'][] = [
"@context" => "http://iiif.io/api/search/0/context.json",
"@id" => $hocr_search_url,
"profile" => "http://iiif.io/api/search/0/search",
"label" => t("Search inside this work"),
];
}
}

/**
Expand Down

0 comments on commit 60a1678

Please sign in to comment.