Skip to content

Commit

Permalink
ISSUE-69: Respect config.yml database credentials if set.
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored and vishalkhode1 committed Dec 6, 2024
1 parent 5f39a18 commit 52acbb4
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 52acbb4

Please sign in to comment.