You are here

public function Migrator::migrate 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::migrate()

Migrates a single entity.

Parameters

string $entity_type_id: The entity type ID.

object $item: The relevant entity information, as returned from query(). This will include the entity ID and values of the scheduled_moderation_state and scheduled_publication fields. Will also include the revision ID and langcode, if the entity type is revisionable and translatable, respectively.

1 call to Migrator::migrate()
Migrator::migrateAll in modules/lightning_scheduler/src/Migrator.php
Migrates all entities of a specific type.

File

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

Class

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

Namespace

Drupal\lightning_scheduler

Code

public function migrate($entity_type_id, $item) {
  $storage = $this->entityTypeManager
    ->getStorage($entity_type_id);
  $entity = $this
    ->load($storage, $item);

  // A horrible hack to work around Content Moderation's opinions being a
  // little too strong. See lightning_scheduler_entity_presave().
  $entity->existingRevisionId = $entity
    ->getRevisionId();
  $entity
    ->set('scheduled_transition_date', $item->scheduled_publication)
    ->set('scheduled_transition_state', $item->scheduled_moderation_state)->original
    ->set('scheduled_transition_date', NULL)
    ->set('scheduled_transition_state', NULL);
  $storage
    ->save($entity);
}