You are here

public function Migrator::completeMigration in Lightning Workflow 8.2

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

Completes the migration for a single entity type.

If the scheduled_publication or scheduled_moderation_state fields have been overridden, those overrides will be deleted in order to revert the fields and a message will be displayed reminding the user to remove those fields from their exported config.

Parameters

string $entity_type_id: The entity type ID.

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

File

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

Class

Migrator
This class is final because the migration is not an API and should not be extended or re-used.

Namespace

Drupal\lightning_scheduler

Code

public function completeMigration($entity_type_id) {
  $storage = $this->entityTypeManager
    ->getStorage('base_field_override');
  $overridden_fields = $storage
    ->getQuery()
    ->condition('entity_type', $entity_type_id)
    ->condition('field_name', [
    'scheduled_publication',
    'scheduled_moderation_state',
  ])
    ->execute();
  if ($overridden_fields) {
    $overridden_fields = $storage
      ->loadMultiple($overridden_fields);
    $storage
      ->delete($overridden_fields);
    $message = $this
      ->t('Overridden scheduled_publication and scheduled_moderation_state fields were detected. They have been reverted, but you must remember to remove them from your exported config.');
    $this->messenger
      ->addWarning($message);
  }

  // Base fields have been reverted, and the migration is now complete.
  $migrations = array_diff($this
    ->getMigrations(), [
    $entity_type_id,
  ]);
  $this
    ->setMigrations($migrations);
}