You are here

protected function TransitionManager::getTransitionable in Lightning Workflow 8.3

Same name and namespace in other branches
  1. 8.2 modules/lightning_scheduler/src/TransitionManager.php \Drupal\lightning_scheduler\TransitionManager::getTransitionable()

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.

\Drupal\Core\Datetime\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 modules/lightning_scheduler/src/TransitionManager.php
Executes all scheduled transitions for a particular entity type.

File

modules/lightning_scheduler/src/TransitionManager.php, line 230

Class

TransitionManager
Executes scheduled transition changes.

Namespace

Drupal\lightning_scheduler

Code

protected 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));
  }
}