From 96cb4f2cc445a43cf9d4aa97d7b4b25b4f471cbb Mon Sep 17 00:00:00 2001 From: ajstanley Date: Wed, 26 Jun 2024 13:55:57 -0300 Subject: [PATCH] added check --- islandora.module | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/islandora.module b/islandora.module index 8fa478a7f..ed1abb43e 100644 --- a/islandora.module +++ b/islandora.module @@ -549,10 +549,8 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie $mapper = \Drupal::service('islandora.entity_mapper'); $flysystem_config = Settings::get('flysystem'); $fedora_root = $flysystem_config['fedora']['config']['root']; - $fedora_root = rtrim($fedora_root, '/'); - if ($entity->getEntityTypeId() == 'media') { - // Check if the source file is in Fedora or not. + // Check existence of source file. $media_source_service = \Drupal::service('islandora.media_source_service'); $source_file = $media_source_service->getSourceFile($entity); if (!$source_file) { @@ -566,6 +564,10 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie ); return; } + if (!$fedora_root) { + return; + } + $fedora_root = rtrim($fedora_root, '/'); $uri = $source_file->getFileUri(); $scheme = \Drupal::service('stream_wrapper_manager')->getScheme($uri); $flysystem_config = Settings::get('flysystem'); @@ -584,6 +586,9 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie } else { // All non-media entities do the UUID -> pair tree thang. + if (!$fedora_root) { + return; + } $path = $mapper->getFedoraPath($entity->uuid()); $path = trim($path, '/'); $fedora_uri = "$fedora_root/$path"; @@ -608,7 +613,6 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie } } } - /** * Implements hook_preprocess_views_view_table(). *