original_string: public function preImport(CommandData $commandData) {
      $userid = $commandData->input()->getOption('userid');
      if ($userid) {
        $account = User::load($userid);
        $accountSwitcher = \Drupal::service('account_switcher');
        $userSession = new UserSession([
          'uid'   => $account->id(),
          'name'  => $account->getUsername(),
          'roles' => $account->getRoles(),
        ]);
        $accountSwitcher->switchTo($userSession);
        $this->logger()->notice(
            dt(
                'Now acting as user ID @id',
                ['@id' => \Drupal::currentUser()->id()]
              )
        );
      }
    }
code: public function preImport(CommandData $commandData) {
      $userid = $commandData->input()->getOption('userid');
      if ($userid) {
        $account = User::load($userid);
        $accountSwitcher = \Drupal::service('account_switcher');
        $userSession = new UserSession([
          'uid'   => $account->id(),
          'name'  => $account->getUsername(),
          'roles' => $account->getRoles(),
        ]);
        $accountSwitcher->switchTo($userSession);
        $this->logger()->notice(
            dt(
                'Now acting as user ID @id',
                ['@id' => \Drupal::currentUser()->id()]
              )
        );
      }
    }
code_tokens: public function preImport ( CommandData $ commandData ) { $ userid = $ commandData -> input ( ) -> getOption ( 'userid' ) ; if ( $ userid ) { $ account = User :: load ( $ userid ) ; $ accountSwitcher = \ Drupal :: service ( 'account_switcher' ) ; $ userSession = new UserSession ( [ 'uid' => $ account -> id ( ) , 'name' => $ account -> getUsername ( ) , 'roles' => $ account -> getRoles ( ) , ] ) ; $ accountSwitcher -> switchTo ( $ userSession ) ; $ this -> logger ( ) -> notice ( dt ( 'Now acting as user ID @id' , [ '@id' => \ Drupal :: currentUser ( ) -> id ( ) ] ) ) ; } }
docstring: Switch the active user account to perform the import.
  
  @hook pre-command migrate:import
docstring_tokens: Switch the active user account to perform the import .