You are here

function _content_moderation_notifications_ensure_revision in Content Moderation Notifications 8.3

Same name and namespace in other branches
  1. 8.2 content_moderation_notifications.module \_content_moderation_notifications_ensure_revision()

Attach the last untouched revision to the entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

1 call to _content_moderation_notifications_ensure_revision()
content_moderation_notifications_entity_presave in ./content_moderation_notifications.module
Implements hook_entity_presave().

File

./content_moderation_notifications.module, line 73
Hook implementations for the content moderation notifications module.

Code

function _content_moderation_notifications_ensure_revision(EntityInterface $entity) {
  $notification_info = Drupal::service('content_moderation_notifications.notification_information');
  if ($notification_info
    ->isModeratedEntity($entity) && !isset($entity->last_revision)) {
    $entity->last_revision = $notification_info
      ->getLatestRevision($entity
      ->getEntityTypeId(), $entity
      ->id());
  }
}