SO I am trying to build out a master config file to use with deployment similar to that in EE2 for EE3. In the include, I have the following:
$config['database'] = array (
'expressionengine' => array (
'hostname' => 'localhost',
'username' => 'local-UN',
'password' => 'local-pw',
'database' => 'local-db',
'dbdriver' => 'mysqli',
'dbprefix' => 'exp_',
'pconnect' => FALSE
),
'localhost' => array (
'hostname' => 'localhost',
'username' => 'local-UN',
'password' => 'local-pw',
'database' => 'local-db',
'dbdriver' => 'mysqli',
'dbprefix' => 'exp_',
'pconnect' => FALSE
),
'production' => array (
'hostname' => 'external-server',
'username' => 'ext-UN',
'password' => 'ext-pw',
'database' => 'ext-db',
'dbdriver' => 'mysqli',
'dbprefix' => 'exp_',
'pconnect' => FALSE
)
);
The reason I left the 'expressionengine' database in there is because of the call for it in DBConfig.php which I'll show in a moment. I know the databases are being populated because when I output print_r(ee()->config->config);
I get the database array as this:
[cache_driver] => file
[database] => Array
(
[expressionengine] => Array
(
[hostname] => localhost
[username] => local-UN
[password] => local-pw
[database] => local-db
[dbdriver] => mysqli
[dbprefix] => exp_
[pconnect] =>
)
[localhost] => Array
(
[hostname] => localhost
[username] => local-UN
[password] => local-pw
[database] => local-db
[dbdriver] => mysqli
[dbprefix] => exp_
[pconnect] =>
)
[production] => Array
(
[hostname] => external-server
[username] => ext-UN
[password] => ext-pw
[database] => ext-db
[dbdriver] => mysqli
[dbprefix] => exp_
[pconnect] =>
)
)
[db_port] =>
The issue I'm having is getting around the following inside the DBConfig.php file:
/**
* ExpressionEngine Database Config Class
*
* @package ExpressionEngine
* @subpackage Core
* @category Core
* @author EllisLab Dev Team
* @link https://ellislab.com
*/
class DBConfig implements Config {
protected $delegate;
protected $active_group;
protected $defaults = array(
'port' => 3306,
'hostname' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => '',
'dbdriver' => 'mysqli',
'pconnect' => FALSE,
'dbprefix' => 'exp_',
'swap_pre' => 'exp_',
'db_debug' => TRUE,
'cache_on' => FALSE,
'autoinit' => FALSE,
'char_set' => 'utf8',
'dbcollat' => 'utf8_unicode_ci',
'cachedir' => '', // Set in constructor
);
/**
* Create new Database Config object
*
* @param ConfigFile $config Config\File object
*/
public function __construct(ConfigFile $config)
{
$this->delegate = $config;
$this->active_group = $this->delegate->get(
'database.active_group',
'expressionengine'
);
$this->defaults['cachedir'] = rtrim(APPPATH, '/').'/user/cache/db_cache/';
}
Is there a way to dynamically pass the $active_group
into the DBConfig class?