You are here

protected function StateChange::loadLatestRevision in Workbench Moderation Actions 8

Loads the latest revision of an entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: Content entity.

Return value

\Drupal\Core\Entity\ContentEntityInterface The latest revision of an entity.

2 calls to StateChange::loadLatestRevision()
StateChange::access in src/Plugin/Action/StateChange.php
Checks object access.
StateChange::execute in src/Plugin/Action/StateChange.php
Executes the plugin.

File

src/Plugin/Action/StateChange.php, line 120

Class

StateChange
Publishes a media entity.

Namespace

Drupal\workbench_moderation_actions\Plugin\Action

Code

protected function loadLatestRevision(ContentEntityInterface $entity) {
  $original_entity = $this->moderationInfo
    ->getLatestRevision($entity
    ->getEntityTypeId(), $entity
    ->id());
  if (!$entity
    ->isDefaultTranslation() && $original_entity
    ->hasTranslation($entity
    ->language()
    ->getId())) {
    $original_entity = $original_entity
      ->getTranslation($entity
      ->language()
      ->getId());
  }
  return $original_entity;
}