You are here

public function MigrationCommands::purge in Lightning Workflow 8.2

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

Deletes old scheduled transition data for an entity type without migrating.

@command lightning:scheduler:purge

Parameters

$entity_type_id: The entity type ID to migrate.

File

modules/lightning_scheduler/src/Commands/MigrationCommands.php, line 91

Class

MigrationCommands
Provides Drush commands for migrating scheduler data to the new base fields.

Namespace

Drupal\lightning_scheduler\Commands

Code

public function purge($entity_type_id) {
  $out = $this
    ->output();
  $entity_types = $this->migrator
    ->getEntityTypesToMigrate((array) $entity_type_id);
  if (empty($entity_types)) {
    $out
      ->writeln('The given entity type either does not need to be migrated, or it has already been migrated or purged.');
    return;
  }
  $message = "You are about to purge existing scheduled transitions for the given entity type. This will permanently delete scheduled transitions and cannot be undone.";
  $out
    ->writeln($message);
  $continue = $this
    ->confirm('Continue?');
  if (empty($continue)) {
    return;
  }
  $this->migrator
    ->purge($entity_type_id, 'scheduled_publication');
  $this->migrator
    ->purge($entity_type_id, 'scheduled_moderation_state');
  $this->migrator
    ->completeMigration($entity_type_id);
}