Skip to content
Permalink
Browse files

[site:install] Small improvements (#4061)

* 1

* 2

* 3

* Update InstallCommand.php
  • Loading branch information...
mondrake authored and enzolutions committed May 23, 2019
1 parent ac553b7 commit 131bb18b2007508b77933aa99879fc1688527ba0
Showing with 17 additions and 9 deletions.
  1. +17 −9 src/Command/Site/InstallCommand.php
@@ -180,6 +180,14 @@ protected function configure()
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
// If Drupal is already installed, and --force is not set, there's no
// point to continue.
$database = Database::getConnectionInfo();
if (!empty($database['default']) && Database::isActiveConnection() && !$input->getOption('force')) {
$this->getIo()->error($this->trans('commands.site.install.messages.already-installed'));
exit(1);
}
// --profile option
$profile = $input->getArgument('profile');
if (!$profile) {
@@ -225,8 +233,7 @@ function ($profile) {
$is_database_info_set = false;
// Use default database setting if is available
$database = Database::getConnectionInfo();
// Use default database setting if they are available.
if (!empty($database['default'])) {
$this->getIo()->info(
sprintf(
@@ -239,7 +246,7 @@ function ($profile) {
$is_database_info_set = true;
}
// Use the --db-url argument if it is entered and valid
// Use the db-url argument if it is entered and valid.
if (!$is_database_info_set && !empty($input->getArgument('db-url'))) {
try {
$database = Database::convertDbUrlToConnectionInfo($input->getArgument('db-url'), $this->appRoot);
@@ -253,15 +260,16 @@ function ($profile) {
);
$is_database_info_set = true;
} catch (\Exception $e) {
$this->getIo()->warning('Invalid --db-url argument: ' . $e->getMessage());
$this->getIo()->warning('Invalid db-url argument: ' . $e->getMessage());
}
}
// Interact if database info is still not available
if (!$is_database_info_set) {
// --db-type option
if (!$input->getOption('db-type')) {
$dbType = $input->getOption('db-type');
if (!$dbType) {
$databases = $this->site->getDatabaseTypes();
$dbType = $this->getIo()->choice(
$this->trans('commands.migrate.setup.questions.db-type'),
@@ -398,12 +406,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$database_install = $database['default'];
}
// Use the --db-url argument if it is entered and valid
// Use the db-url argument if it is entered and valid
if (!$database_install && !empty($input->getArgument('db-url'))) {
try {
$database_install = Database::convertDbUrlToConnectionInfo($input->getArgument('db-url'), $this->appRoot);
} catch (\Exception $e) {
$this->getIo()->error('Invalid --db-url argument: ' . $e->getMessage());
$this->getIo()->error('Invalid db-url argument: ' . $e->getMessage());
return 1;
}
}
@@ -434,7 +442,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
// Database option defaults.
// Cleanup an installed database.
if ($input->getOption('force') && Database::isActiveConnection()) {
$connection = Database::getConnection();
if ($connection->driver() === 'sqlite') {
@@ -575,7 +583,7 @@ protected function runInstaller($database, $uri) {
$this->getIo()->error($this->trans('commands.site.install.messages.already-installed'));
return 1;
} catch (\Exception $e) {
$this->getIo()->error($e->getMessage());
$this->getIo()->error(html_entity_decode(strip_tags($e->getMessage()), ENT_QUOTES));
return 1;
}

0 comments on commit 131bb18

Please sign in to comment.
You can’t perform that action at this time.