Skip to content

Commit

Permalink
DGIR-142 : fix linting error
Browse files Browse the repository at this point in the history
  • Loading branch information
Prashant-bd committed Dec 22, 2023
1 parent 306d40f commit 5ba121e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Normalizer/V3/ContentEntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,25 @@ public function normalize($object, $format = NULL, array $context = []) {
// Load the entity type manager.
$entity_type_manager = \Drupal::entityTypeManager();

// Get term id for Thumbnail Image.
$term_storage = $entity_type_manager->getStorage('taxonomy_term');
$term = $term_storage->loadByProperties([
'name' => 'Thumbnail Image',
'vid' => 'islandora_media_use',
]);

// Check if the term is found.
if (!empty($term)) {
// Get the term ID.
$term_id = reset($term)->id();
}

// Get the storage handler for the media entity.
$media_storage = $entity_type_manager->getStorage('media');

// Load a single media entity by properties.
$media_entities = $media_storage->loadByProperties([
'field_media_use' => 349, // Need to make it dynamic after verification.
'field_media_use' => $term_id, // Need to make it dynamic after verification.
'field_media_of' => $object->id(),
]);

Expand All @@ -132,9 +145,9 @@ public function normalize($object, $format = NULL, array $context = []) {
// Get the file ID from the file field.
$file_id = $media_entity->get('field_media_image')->target_id;
$file = $entity_type_manager->getStorage('file')->load($file_id);
}

$normalized['thumbnail'] = $this->generateBody($file);
$normalized['thumbnail'] = $this->generateBody($file);
}
}
return $this->normalizeEntityFields($object, $format, $context, $normalized);
}
Expand Down

0 comments on commit 5ba121e

Please sign in to comment.