Browse Source

Merge branch 'versioning' of https://github.com/asulibraries/islandora into versioning

pull/733/head
dannylamb 6 years ago
parent
commit
6d3951e063
  1. 22
      src/EventGenerator/EventGenerator.php

22
src/EventGenerator/EventGenerator.php

@ -99,6 +99,13 @@ class EventGenerator implements EventGeneratorInterface {
$event["summary"] = ucfirst($data["event"]) . " a " . ucfirst($entity_type); $event["summary"] = ucfirst($data["event"]) . " a " . ucfirst($entity_type);
} }
if ($entity->getEntityType()->isRevisionable()) {
$isNewRev = $this->isNewRevision($entity);
if ($isNewRev) {
$event["object"]["isNewVersion"] = $isNewRev;
}
}
// Add REST links for non-file entities. // Add REST links for non-file entities.
if ($entity_type != 'file') { if ($entity_type != 'file') {
$event['object']['url'][] = [ $event['object']['url'][] = [
@ -145,4 +152,19 @@ class EventGenerator implements EventGeneratorInterface {
return json_encode($event); return json_encode($event);
} }
/**
* Method to check if an entity is a new revision.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* Drupal Entity.
*
* @return bool
* Is new version.
*/
protected function isNewRevision(EntityInterface $entity) {
$bundle_entity_type = $entity->getEntityType()->getBundleEntityType();
$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type)->load($entity->bundle());
return $bundle_entity->shouldCreateNewRevision();
}
} }

Loading…
Cancel
Save