You are here

public function InstallProfileCommands::switch in Helper 8

Switches install profiles.

@command install-profile:switch @alias ips @usage drush install-profile:switch minimal Switches from the current install profile to the minimal install profile.

Parameters

string $profile: The install profile.

int $schema_version: The schema version to set for the install profile.

Throws

\Drush\Exceptions\UserAbortException If the user aborted the confirmation.

File

src/Commands/InstallProfileCommands.php, line 48

Class

InstallProfileCommands
Drush commands for working with install profiles.

Namespace

Drupal\helper\Commands

Code

public function switch($profile, $schema_version = NULL) {
  $args = [
    '!current' => \Drupal::installProfile(),
    '!new' => $profile,
  ];
  try {
    $this->installProfile
      ->validateProfile($profile);
  } catch (InstallerException $exception) {
    $this
      ->io()
      ->error($exception
      ->getMessage());
  }
  if (!$this
    ->io()
    ->confirm(dt('Do you want to switch from the !current install profile to the !new install profile?', $args))) {
    throw new UserAbortException();
  }
  if (!$this
    ->getConfig()
    ->simulate()) {
    $this->installProfile
      ->switch($profile, $schema_version);
  }
  $this
    ->io()
    ->success(dt('Updated install profile from !current to !new.', $args));
}