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

Loading…
Cancel
Save