Skip to content

Commit

Permalink
Merge pull request #78 from acquia/ISSUE-69
Browse files Browse the repository at this point in the history
ISSUE-69: Respect config.yml database credentials if set.
  • Loading branch information
vishalkhode1 authored Dec 5, 2024
2 parents 5c010ff + 39e8f38 commit 8e5fed3
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/Drush/Commands/SettingsDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,18 @@ class SettingsDrushCommands extends BaseDrushCommands {
description: 'Generates the settings.php for site2 passing db credentials.',
)]
public function initSettings(array $options = [
'database' => 'drupal',
'username' => 'drupal',
'password' => 'drupal',
'host' => 'localhost',
'port' => "3306",
'database' => NULL,
'username' => NULL,
'password' => NULL,
'host' => NULL,
'port' => NULL,
]): int {
$db["drupal"]["db"] = [
'database' => $options['database'],
'username' => $options['username'],
'password' => $options['password'],
'host' => $options['host'],
'port' => $options['port'],
];
$db = [];
$db['drupal']['db'] = array_filter(
$options,
fn($value, $key) => in_array($key, ['database', 'username', 'password', 'host', 'port']) && $value !== NULL,
ARRAY_FILTER_USE_BOTH
);
try {
$site_directory = $this->getSitesSubdirFromUri($this->getConfigValue("docroot"), $this->getConfigValue("drush.uri"));
$settings = new Settings($this->getConfigValue("docroot"), $site_directory);
Expand Down

0 comments on commit 8e5fed3

Please sign in to comment.