Skip to content

Commit

Permalink
DDST-554: Fix linting error and remove extra lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
prashant-dgi committed Oct 17, 2024
1 parent e777765 commit 6f39178
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/Plugin/OaiMetadataMap/DgiStandard.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\GeneratedUrl;
use Drupal\image\ImageStyleInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\image\ImageStyleInterface;
use Drupal\dgi_image_discovery\ImageDiscovery;
use Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList;
use Drupal\islandora\IslandoraUtils;
Expand Down Expand Up @@ -166,7 +166,7 @@ class DgiStandard extends OaiMetadataMapBase implements ContainerFactoryPluginIn
protected ImageDiscovery $imageDiscovery;

/**
* URL generator.
* The URL generator.
*
* @var \Drupal\dgi_image_discovery\UrlGeneratorPluginBase
*/
Expand Down Expand Up @@ -399,24 +399,20 @@ protected function addPersistentUrl(ContentEntityInterface $entity, $dest, $alia
* The destination index for the thumbnail.
*/
public function addThumbnail(ContentEntityInterface $entity, $dest) {
$event = $this->imageDiscovery->getImage($entity);
$style_id = 'solr_grid_thumbnail';

if ($event->hasMedia()) {
$style_id = 'solr_grid_thumbnail';
// Load the image style.
$style = $this->entityTypeManager->getStorage('image_style')->load($style_id);

// Load the image style
$style = $this->entityTypeManager->getStorage('image_style')->load($style_id);
if ($style instanceof ImageStyleInterface) {
// Generate the URL using the Deferred plugin.
$generated_url = $this->urlGenerator->generate($entity, $style);

if ($style instanceof ImageStyleInterface) {
// Generate the URL using the Deferred plugin
$generated_url = $this->urlGenerator->generate($entity, $style);

// Add the resolved image URL to the elements array
if ($generated_url instanceof GeneratedUrl) {
$url = $generated_url->getGeneratedUrl();
if (!empty($url)) {
$this->elements[$dest][] = $url;
}
// Add the resolved image URL to the elements array.
if ($generated_url instanceof GeneratedUrl) {
$url = $generated_url->getGeneratedUrl();
if (!empty($url)) {
$this->elements[$dest][] = $url;
}
}
}
Expand Down

0 comments on commit 6f39178

Please sign in to comment.