You are here

private function ModerationStateWidget::getLatestRevision in Lightning Workflow 8.3

Loads the latest revision of an entity.

This is a shim around ModerationInformationInterface::getLatestRevision(), which was replaced by calling methods on the entity storage handler in Drupal 8.8.

Parameters

string $entity_type_id: The entity type ID.

mixed $entity_id: The entity ID.

Return value

\Drupal\Core\Entity\EntityInterface|null The latest revision of the entity, if one exists.

1 call to ModerationStateWidget::getLatestRevision()
ModerationStateWidget::formElement in modules/lightning_scheduler/src/Plugin/Field/FieldWidget/ModerationStateWidget.php
Returns the form for a single field widget.

File

modules/lightning_scheduler/src/Plugin/Field/FieldWidget/ModerationStateWidget.php, line 179

Class

ModerationStateWidget
Scheduler extension of Content Moderation's widget.

Namespace

Drupal\lightning_scheduler\Plugin\Field\FieldWidget

Code

private function getLatestRevision($entity_type_id, $entity_id) {
  $storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  if ($storage instanceof RevisionableStorageInterface && method_exists($storage, 'getLatestRevisionId')) {
    $revision_id = $storage
      ->getLatestRevisionId($entity_id);
    return isset($revision_id) ? $storage
      ->loadRevision($revision_id) : NULL;
  }
  else {

    // Use call_user_func() here because our deprecation testing tools are not
    // smart enough to recognize the actual code path that leads here.
    return call_user_func([
      $this->moderationInformation,
      'getLatestRevision',
    ], $entity_type_id, $entity_id);
  }
}