Skip to content
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

Term revisions can now go to Fedora #1043

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/EventGenerator/EventGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Drupal\islandora\EventGenerator;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Site\Settings;
use Drupal\islandora\IslandoraUtils;
use Drupal\islandora\MediaSource\MediaSourceService;
use Drupal\user\UserInterface;
use Drupal\Core\Site\Settings;
use Drupal\media\Entity\Media;
use Drupal\Core\Entity\EntityStorageInterface;

/**
* The default EventGenerator implementation.
Expand Down Expand Up @@ -186,26 +186,26 @@ protected function isNewRevision(EntityInterface $entity) {
$revision_ids = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->revisionIds($entity);
return count($revision_ids) > 1;
}
elseif ($entity->getEntityTypeId() == "media") {
$mediaStorage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
return count($this->getRevisionIds($entity, $mediaStorage)) > 1;
elseif (in_array($entity->getEntityTypeId(), ["media", "taxonomy_term"])) {
$entity_storage = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId());
return count($this->getRevisionIds($entity, $entity_storage)) > 1;
}
}

/**
* Method to get the revisionIds of a media object.
* Method to get the revisionIds of an entity.
*
* @param \Drupal\media\Entity\Media $media
* Media object.
* @param \Drupal\Core\Entity\EntityStorageInterface $media_storage
* Media Storage.
* @param \Drupal\entity\Entity\ContentEntityInterface $entity
* Entity instance such as a Media or Taxonomy term.
* @param \Drupal\Core\Entity\EntityStorageInterface $entity_storage
* Entity Storage.
*/
protected function getRevisionIds(Media $media, EntityStorageInterface $media_storage) {
$result = $media_storage->getQuery()
protected function getRevisionIds(ContentEntityInterface $entity, EntityStorageInterface $entity_storage) {
$result = $entity_storage->getQuery()
->allRevisions()
->accessCheck(TRUE)
->condition($media->getEntityType()->getKey('id'), $media->id())
->sort($media->getEntityType()->getKey('revision'), 'DESC')
->condition($entity->getEntityType()->getKey('id'), $entity->id())
->sort($entity->getEntityType()->getKey('revision'), 'DESC')
->execute();
return array_keys($result);
}
Expand Down
Loading