InstallProfileCommands.php in Helper 8
File
src/Commands/InstallProfileCommands.php
View source
<?php
namespace Drupal\helper\Commands;
use Drupal\Core\Installer\Exception\InstallerException;
use Drupal\helper\InstallProfile;
use Drush\Commands\DrushCommands;
use Drush\Exceptions\UserAbortException;
class InstallProfileCommands extends DrushCommands {
protected $installProfile;
public function __construct(InstallProfile $installProfile) {
$this->installProfile = $installProfile;
}
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));
}
}