You are here

private function TransitionManager::getTransitionable in Lightning Scheduler 8

Returns all transitionable entities of a given type.

The entity type is assumed to have the scheduled_transition_date field.

Parameters

string $entity_type_id: The entity type ID.

DrupalDateTime $now: The time that processing began.

Return value

\Generator An iterable of the latest revisions of all transitionable entities of the given type.

1 call to TransitionManager::getTransitionable()
TransitionManager::process in src/TransitionManager.php
Executes all scheduled transitions for a particular entity type.

File

src/TransitionManager.php, line 204

Class

TransitionManager
@internal This is an internal part of Lightning Scheduler and may be changed or removed at any time without warning. It should not be used by external code in any way.

Namespace

Drupal\lightning_scheduler

Code

private function getTransitionable($entity_type_id, DrupalDateTime $now) {
  $storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  $now = $now
    ->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

  // Entities are transitionable if its latest revision has any transitions
  // scheduled now or in the past.
  $IDs = $storage
    ->getQuery()
    ->latestRevision()
    ->accessCheck(FALSE)
    ->condition('scheduled_transition_date.value', $now, '<=')
    ->execute();
  foreach (array_keys($IDs) as $revision_id) {
    (yield $storage
      ->loadRevision($revision_id));
  }
}