Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi, this code works for me, and I expect it might work for others too. That said, I'm a beginner in object oriented programming and Drupal 8, so there probably is a nicer way to get this issue fixed. The database settings are created in Drupal\Core\Site\Settings, and this is a final class. As I understand it this makes it impossible to extend. I ended up copying code from Drupal core to drupal console, which is not nice.
The database settings are read from drushrc.php which is located in the site directory (same location as settings.php).
This is how the database settings exist in my drusrc.php:
$options['db_type'] = 'mysql';
$options['db_host'] = 'localhost';
$options['db_port'] = '3306';
$options['db_passwd'] = 'averystrongpass';
$options['db_name'] = 'thedbname';
$options['db_user'] = 'thedbusername';
I expect aegir always makes the settings available in this way in drushrc.php, but I'm not sure. I haven't looked into the aegir project to check how drushrc.php is created. So there is a possibility that in other environments the settings are stored differently. Nor do I know if there are situations where aegir sites have more then 1 database connection, and how this works if so.