Browse Source

Add try() wrapper to IIIF manifest title generate function.

pull/869/head
Alexander O'Neill 3 years ago
parent
commit
71b1cb5d64
  1. 5
      modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

5
modules/islandora_iiif/src/Plugin/views/style/IIIFManifest.php

@ -130,7 +130,6 @@ class IIIFManifest extends StylePluginBase {
$content_path = implode('/', $url_components); $content_path = implode('/', $url_components);
$iiif_base_id = $request_host . '/' . $content_path; $iiif_base_id = $request_host . '/' . $content_path;
// @see https://iiif.io/api/presentation/2.1/#manifest // @see https://iiif.io/api/presentation/2.1/#manifest
$json += [ $json += [
'@type' => 'sc:Manifest', '@type' => 'sc:Manifest',
@ -272,6 +271,7 @@ class IIIFManifest extends StylePluginBase {
*/ */
public function getEntityTitle(string $content_path): string { public function getEntityTitle(string $content_path): string {
$entity_title = $this->t('IIIF Manifest'); $entity_title = $this->t('IIIF Manifest');
try {
$params = \Drupal\Core\Url::fromUserInput($content_path)->getRouteParameters(); $params = \Drupal\Core\Url::fromUserInput($content_path)->getRouteParameters();
if (isset($params['node'])) { if (isset($params['node'])) {
$node = \Drupal\node\Entity\Node::load($params['node']); $node = \Drupal\node\Entity\Node::load($params['node']);
@ -280,6 +280,9 @@ class IIIFManifest extends StylePluginBase {
$media = \Drupal\media\Entity\Media::load($params['media']); $media = \Drupal\media\Entity\Media::load($params['media']);
$entity_title = $media->getName(); $entity_title = $media->getName();
} }
} catch (\InvalidArgumentException $e) {
}
return $entity_title; return $entity_title;
} }

Loading…
Cancel
Save