Skip to content

Commit 27148ec

Browse files
authored
Merge branch 'develop-v4' into remove/custom-conf
2 parents 11cd78b + 0b077e0 commit 27148ec

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

php/utils.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Composer\Semver\Semver;
99
use EE;
1010
use EE\Iterators\Transform;
11+
use Mustangostang\Spyc;
1112

1213
const PHAR_STREAM_PREFIX = 'phar://';
1314

@@ -1623,3 +1624,19 @@ function get_curl_info( $url, $port = 80, $port_info = false, $auth = false ) {
16231624

16241625
return curl_getinfo( $ch, CURLINFO_HTTP_CODE );
16251626
}
1627+
1628+
/**
1629+
* Function to get config value for a given key.
1630+
*
1631+
* @param string $key Key to search in config file.
1632+
* @param string|null $default Default value of the given key.
1633+
*
1634+
* @return string|null value of the asked key.
1635+
*/
1636+
function get_config_value( $key, $default = null ) {
1637+
1638+
$config_file_path = getenv( 'EE_CONFIG_PATH' ) ? getenv( 'EE_CONFIG_PATH' ) : EE_ROOT_DIR . '/config/config.yml';
1639+
$existing_config = Spyc::YAMLLoad( $config_file_path );
1640+
1641+
return empty( $existing_config[ $key ] ) ? $default : $existing_config[ $key ];
1642+
}

0 commit comments

Comments
 (0)