Browse Source

Media count

main
astanley 7 months ago
parent
commit
1584495270
  1. 7
      src/Controller/RegenerateDerivativesController.php

7
src/Controller/RegenerateDerivativesController.php

@ -48,10 +48,11 @@ final class RegenerateDerivativesController extends ControllerBase {
$referer = $request->headers->get('referer'); $referer = $request->headers->get('referer');
$media = $this->islandoraUtils->getMediaReferencingNodeAndTerm($node, $term); $media = $this->islandoraUtils->getMediaReferencingNodeAndTerm($node, $term);
if (count($media) == 0) { $media_count = count("media");
if ($media_count == 0) {
$status = $this->t("Derivative generation requires a media tagged Original File."); $status = $this->t("Derivative generation requires a media tagged Original File.");
} }
if (count($media) === 1) { if ($media_count === 1) {
$media = $this->entityTypeManager()->getStorage('media')->load(reset($media)); $media = $this->entityTypeManager()->getStorage('media')->load(reset($media));
$this->islandoraUtils->executeDerivativeReactions( $this->islandoraUtils->executeDerivativeReactions(
'\Drupal\islandora\Plugin\ContextReaction\DerivativeReaction', '\Drupal\islandora\Plugin\ContextReaction\DerivativeReaction',
@ -60,7 +61,7 @@ final class RegenerateDerivativesController extends ControllerBase {
); );
$status = $this->t('Derivative generation requests were added to the queue.'); $status = $this->t('Derivative generation requests were added to the queue.');
} }
if (count($media) > 1) { if ($media_count > 1) {
$status = $this->t("Derivative generation is unreliable when there are more than one original files associated with a node."); $status = $this->t("Derivative generation is unreliable when there are more than one original files associated with a node.");
} }
$this->messenger()->addStatus($status); $this->messenger()->addStatus($status);

Loading…
Cancel
Save