You are here

public function Migrator::query in Lightning Workflow 8.3

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

Queries for all entities of a specific type which need to be migrated.

Parameters

string $entity_type_id: The entity type ID.

Return value

\Drupal\Core\Entity\Query\QueryInterface The prepared query.

File

modules/lightning_scheduler/src/Migrator.php, line 131

Class

Migrator
The migration is not an API and should not be extended or re-used.

Namespace

Drupal\lightning_scheduler

Code

public function query($entity_type_id) {
  $entity_type = $this->entityTypeManager
    ->getDefinition($entity_type_id);
  $fields = [
    $entity_type
      ->getKey('id'),
    'scheduled_publication',
    'scheduled_moderation_state',
  ];
  if ($entity_type
    ->isRevisionable()) {
    array_push($fields, $entity_type
      ->getKey('revision'));
  }
  if ($entity_type
    ->isTranslatable()) {
    array_push($fields, $entity_type
      ->getKey('langcode'));
  }
  $table = $entity_type
    ->getRevisionDataTable() ?: $entity_type
    ->getDataTable();
  return $this->database
    ->select($table)
    ->fields($table, $fields)
    ->isNotNull('scheduled_publication')
    ->isNotNull('scheduled_moderation_state');
}