public function postImport($result, CommandData $commandData) {
    if ($commandData->input()->getOption('userid')) {
      $accountSwitcher = \Drupal::service('account_switcher');
      $this->logger()->notice(dt(
                                  'Switching back from user @uid.',
                                  ['@uid' => \Drupal::currentUser()->id()]
                                ));
      $accountSwitcher->switchBack();
    }
  }
public function postImport($result, CommandData $commandData) {
    if ($commandData->input()->getOption('userid')) {
      $accountSwitcher = \Drupal::service('account_switcher');
      $this->logger()->notice(dt(
                                  'Switching back from user @uid.',
                                  ['@uid' => \Drupal::currentUser()->id()]
                                ));
      $accountSwitcher->switchBack();
    }
  }
public function postImport ( $ result , CommandData $ commandData ) { if ( $ commandData -> input ( ) -> getOption ( 'userid' ) ) { $ accountSwitcher = \ Drupal :: service ( 'account_switcher' ) ; $ this -> logger ( ) -> notice ( dt ( 'Switching back from user @uid.' , [ '@uid' => \ Drupal :: currentUser ( ) -> id ( ) ] ) ) ; $ accountSwitcher -> switchBack ( ) ; } }
Switch the user back once the migration is complete.

@hook post-command migrate:import
Switch the user back once the migration is complete .