You are here

public function ScheduledTransitionsUtility::getTargetRevisionIds in Scheduled Transitions 2.x

Get potential revisions which can be transitioned to.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity a transition is created for.

string $language: The language code.

Return value

array An unordered array of revision IDs.

Overrides ScheduledTransitionsUtilityInterface::getTargetRevisionIds

File

src/ScheduledTransitionsUtility.php, line 176

Class

ScheduledTransitionsUtility
Utilities for Scheduled Transitions module.

Namespace

Drupal\scheduled_transitions

Code

public function getTargetRevisionIds(EntityInterface $entity, string $language) : array {
  $entityStorage = $this->entityTypeManager
    ->getStorage($entity
    ->getEntityTypeId());
  $entityDefinition = $entityStorage
    ->getEntityType();
  $ids = $entityStorage
    ->getQuery()
    ->allRevisions()
    ->condition($entityDefinition
    ->getKey('id'), $entity
    ->id())
    ->condition($entityDefinition
    ->getKey('langcode'), $language)
    ->sort($entityDefinition
    ->getKey('revision'), 'DESC')
    ->addTag(static::QUERY_TAG_TARGET_REVISIONS)
    ->execute();
  return array_keys($ids);
}