-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DDST-554: New roles added to Creator vs Contributor mapping #16
Changes from 1 commit
06d9829
8110e14
881177c
971edd5
e777765
6f39178
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
use Drupal\Core\Field\EntityReferenceFieldItemListInterface; | ||
use Drupal\Core\Field\FieldItemListInterface; | ||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | ||
use Drupal\Core\Url; | ||
use Drupal\Core\Routing\UrlGeneratorInterface; | ||
use Drupal\dgi_image_discovery\ImageDiscovery; | ||
use Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList; | ||
use Drupal\islandora\IslandoraUtils; | ||
|
@@ -164,6 +164,13 @@ class DgiStandard extends OaiMetadataMapBase implements ContainerFactoryPluginIn | |
*/ | ||
protected ImageDiscovery $imageDiscovery; | ||
|
||
/** | ||
* The URL generator. | ||
* | ||
* @var \Drupal\Core\Routing\UrlGeneratorInterface | ||
*/ | ||
protected UrlGeneratorInterface $urlGenerator; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
@@ -174,6 +181,7 @@ public static function create(ContainerInterface $container, array $configuratio | |
$plugin->entityTypeManager = $container->get('entity_type.manager'); | ||
$plugin->utils = $container->get('islandora.utils'); | ||
$plugin->imageDiscovery = $container->get('dgi_image_discovery.service'); | ||
$plugin->urlGenerator = $container->get('url_generator'); | ||
return $plugin; | ||
} | ||
|
||
|
@@ -393,25 +401,18 @@ public function addThumbnail(ContentEntityInterface $entity, $dest) { | |
$event = $this->imageDiscovery->getImage($entity); | ||
|
||
if ($event->hasMedia()) { | ||
$media = $event->getMedia(); | ||
|
||
$fid = $media->getSource()->getSourceFieldValue($media); | ||
$file = $this->entityTypeManager->getStorage('file')->load($fid); | ||
|
||
if ($file) { | ||
$style_id = 'solr_grid_thumbnail'; | ||
$node_id = $entity->id(); | ||
|
||
// Generate the deferred resolution URL. | ||
$url = Url::fromRoute('dgi_image_discovery.deferred_resolution', [ | ||
'node' => $node_id, | ||
'style' => $style_id, | ||
])->setAbsolute(TRUE); | ||
|
||
$resolved_image_url = $url->toString(); | ||
|
||
// Add the resolved image URL to the elements array. | ||
$this->elements[$dest][] = $resolved_image_url; | ||
$style_id = 'solr_grid_thumbnail'; | ||
$node_id = $entity->id(); | ||
|
||
// Use the URL generator to create the deferred resolution URL. | ||
$url = $this->urlGenerator->generateFromRoute('dgi_image_discovery.deferred_resolution', [ | ||
'node' => $node_id, | ||
'style' => $style_id, | ||
], ['absolute' => TRUE]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not the intended URL Generator plugin (is this service even plugin based? Dunno)? Like, was meaning the plugins for the image discovery, in https://github.com/discoverygarden/dgi_image_discovery/tree/main/src/Plugin/dgi_image_discovery/url_generator ... so, using the related plugin manager and getting an instance of the desired plugin. Not sure if it's necessary here to make it fully configurable, but could? Not much configuration on either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @adam-vessey I made code changes, please review. |
||
|
||
// Add the resolved image URL to the elements array. | ||
if (!empty($url)) { | ||
$this->elements[$dest][] = $url; | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this was already setting a thumbnail? ... but it's doing an up-front lookup just to use the deferred thing? Should probably drop the up-front lookup to just always do the deferred thing? Kinda want to suggest making use of the URL generator plugins, instead of directly using the underlying route. |
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still doing an unnecessary lookup. Why bother keeping this if doing the deferred resolution, which expects to handle the lookup separately?