Skip to content

Commit

Permalink
OPENEUROPA-1697: Add drupal.site.generate_db_url parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
ademarco committed Mar 12, 2019
1 parent 417d80f commit c9e003c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ root = true
[*]
end_of_line = LF
indent_style = space
indent_size = 2
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.{json,lock}]
indent_size = 4

[*.yml]
indent_size = 2
1 change: 1 addition & 0 deletions config/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ drupal:
config_dir: ~
existing_config: false
settings_override_file: "settings.override.php"
generate_db_url: true

# Administrator account information.
account:
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/AbstractDrupalCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ public function siteInstall(array $options = [
->sitesSubdir($options['sites-subdir'])
->siteProfile($options['site-profile']);

$task->setGenerateDbUrl($this->getConfig()->get('drupal.site.generate_db_url'));

if (!empty($options['existing-config'])) {
$task->setExistingConfig($options['existing-config']);
}
Expand Down
38 changes: 27 additions & 11 deletions src/Tasks/Drush/Drush.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Drush extends Exec
protected $databaseName = '';
protected $sitesSubdir = '';
protected $existingConfig = false;
protected $generateDbUrl = true;

/**
* Build Drush site install command.
Expand All @@ -38,16 +39,6 @@ class Drush extends Exec
*/
public function siteInstall()
{
$dbArray = [
'scheme' => $this->databaseScheme,
'user' => $this->databaseUser,
'pass' => $this->databasePassword,
'host' => $this->databaseHost,
'port' => $this->databasePort,
'path' => $this->databaseName,
];
$dbUrl = http_build_url($dbArray, $dbArray);

$this->option('-y')
->rawArg("--root=$(pwd)/".$this->root)
->options([
Expand All @@ -58,9 +49,22 @@ public function siteInstall()
'account-name' => $this->accountName,
'account-pass' => $this->accountPassword,
'sites-subdir' => $this->sitesSubdir,
'db-url' => $dbUrl,
], '=');

if ($this->generateDbUrl) {
$dbArray = [
'scheme' => $this->databaseScheme,
'user' => $this->databaseUser,
'pass' => $this->databasePassword,
'host' => $this->databaseHost,
'port' => $this->databasePort,
'path' => $this->databaseName,
];
$dbUrl = http_build_url($dbArray, $dbArray);

$this->option('db-url', $dbUrl, '=');
}

if (!empty($this->existingConfig)) {
$this->option('existing-config');
}
Expand Down Expand Up @@ -271,4 +275,16 @@ public function setExistingConfig($existingConfig)

return $this;
}

/**
* @param bool $generateDbUrl
*
* @return Drush
*/
public function setGenerateDbUrl($generateDbUrl)
{
$this->generateDbUrl = $generateDbUrl;

return $this;
}
}
10 changes: 10 additions & 0 deletions tests/fixtures/simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,13 @@
- "./vendor/bin/drush -y"
not_contains:
- "--existing-config"

- command: "drupal:site-install"
configuration:
drupal:
site:
generate_db_url: false
composer: ''
contains: []
not_contains:
- "--db-url='mysql://127.0.0.1:3306'"
Empty file modified tests/sandbox/.gitkeep
100644 → 100755
Empty file.

0 comments on commit c9e003c

Please sign in to comment.