Skip to content

Commit 0edbdc6

Browse files
committed
Merge branch 'mrrobot47-update/ensure-in-config' into develop-v4
2 parents c1176f6 + 0c14972 commit 0edbdc6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

php/EE/Runner.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -597,34 +597,34 @@ public function init_config() {
597597
* Ensures that vars are present in config. If they aren't, attempts to
598598
* create config file and add vars in it.
599599
*
600-
* @param $var Variable to check.
600+
* @param $var Variable to check.
601601
* @param $default Default value to use if $var is not set.
602602
*/
603-
private function ensure_present_in_config( $var, $default) {
604-
605-
if ( empty($this->config[$var]) ) {
606-
$this->config[$var] = $default ;
607-
608-
$config_file_path = getenv('EE_CONFIG_PATH') ? getenv('EE_CONFIG_PATH') : EE_CONF_ROOT . '/config.yml';
609-
$config_dir_path = dirname( $config_file_path );
603+
public function ensure_present_in_config( $var, $default ) {
604+
$config_file_path = getenv( 'EE_CONFIG_PATH' ) ? getenv( 'EE_CONFIG_PATH' ) : EE_CONF_ROOT . '/config.yml';
605+
$existing_config = Spyc::YAMLLoad( $config_file_path );
606+
if ( ! isset( $existing_config[$var] ) ) {
607+
$this->config[$var] = $default;
608+
$config_dir_path = dirname( $config_file_path );
610609

611610
if ( file_exists( $config_file_path ) ) {
612611
if ( is_readable( $config_file_path ) ) {
613612
if ( is_writable( $config_file_path ) ) {
614-
$existing_config = Spyc::YAMLLoad ( $config_file_path );
613+
$existing_config = Spyc::YAMLLoad( $config_file_path );
615614
$this->add_var_to_config_file( $var, $config_file_path, $existing_config );
615+
616616
return;
617617
}
618-
EE::error("The config file {$config_file_path} is not writable. Please set a config path which is writable in EE_CONFIG_PATH environment variable.");
618+
EE::error( "The config file {$config_file_path} is not writable. Please set a config path which is writable in EE_CONFIG_PATH environment variable." );
619619
}
620-
EE::error("The config file {$config_file_path} is not readable. Please select a config path which is readable in EE_CONFIG_PATH environment variable.");
621-
}
622-
else {
620+
EE::error( "The config file {$config_file_path} is not readable. Please select a config path which is readable in EE_CONFIG_PATH environment variable." );
621+
} else {
623622
if ( is_writable( $config_dir_path ) ) {
624623
$this->add_var_to_config_file( $var, $config_file_path );
624+
625625
return;
626626
}
627-
EE::err("Configuration directory: $config_dir_path is not writable by EasyEngine.");
627+
EE::err( "Configuration directory: $config_dir_path is not writable by EasyEngine." );
628628
}
629629
}
630630
}

0 commit comments

Comments
 (0)