Browse Source

changing to check if the specific entity has more than one revision - too late to actually check if its a new revision

pull/733/head
Eli Zoller 6 years ago
parent
commit
2e7945b1c1
  1. 12
      src/EventGenerator/EventGenerator.php

12
src/EventGenerator/EventGenerator.php

@ -98,13 +98,12 @@ class EventGenerator implements EventGeneratorInterface {
$event["type"] = ucfirst($data["event"]); $event["type"] = ucfirst($data["event"]);
$event["summary"] = ucfirst($data["event"]) . " a " . ucfirst($entity_type); $event["summary"] = ucfirst($data["event"]) . " a " . ucfirst($entity_type);
} }
$isNewRev = FALSE;
if ($entity->getEntityType()->isRevisionable()) { if ($entity->getEntityType()->isRevisionable()) {
\Drupal::logger('islandora')->notice('its revisionable');
$isNewRev = $this->isNewRevision($entity); $isNewRev = $this->isNewRevision($entity);
if ($isNewRev) {
$event["object"]["isNewVersion"] = $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') {
@ -162,9 +161,8 @@ class EventGenerator implements EventGeneratorInterface {
* Is new version. * Is new version.
*/ */
protected function isNewRevision(EntityInterface $entity) { protected function isNewRevision(EntityInterface $entity) {
$bundle_entity_type = $entity->getEntityType()->getBundleEntityType(); $revision_ids = \Drupal::entityTypeManager()->getStorage($entity->getEntityTypeId())->revisionIds($entity);
$bundle_entity = \Drupal::entityTypeManager()->getStorage($bundle_entity_type)->load($entity->bundle()); return count($revision_ids) > 1;
return $bundle_entity->shouldCreateNewRevision();
} }
} }

Loading…
Cancel
Save