Skip to content

Commit

Permalink
added check
Browse files Browse the repository at this point in the history
  • Loading branch information
ajstanley committed Jun 26, 2024
1 parent e36ad17 commit 96cb4f2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions islandora.module
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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');
Expand All @@ -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";
Expand All @@ -608,7 +613,6 @@ function islandora_entity_view(array &$build, EntityInterface $entity, EntityVie
}
}
}

/**
* Implements hook_preprocess_views_view_table().
*
Expand Down

0 comments on commit 96cb4f2

Please sign in to comment.