Added support for setting GRAV_SETUP_PATH by using environment variable

This commit is contained in:
Matias Griese
2020-12-08 13:27:53 +02:00
parent b093aa9fa6
commit fc55a8e49b
2 changed files with 5 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
* Updated unit tests to use codeception 4.1
1. [](#improved)
* Improved `bin/grav install` command
* Added support for setting `GRAV_SETUP_PATH` by using environment variable
1. [](#bugfix)
* Fixed potential error when upgrading Grav
* Fixed broken list in `bin/gpm index` [#3092](https://github.com/getgrav/grav/issues/3092)

View File

@@ -182,7 +182,10 @@ class Setup extends Data
// Pre-load setup.php which contains our initial configuration.
// Configuration may contain dynamic parts, which is why we need to always load it.
// If "GRAV_SETUP_PATH" has been defined, use it, otherwise use defaults.
$file = defined('GRAV_SETUP_PATH') ? GRAV_SETUP_PATH : GRAV_ROOT . '/setup.php';
$file = getenv('GRAV_SETUP_PATH') ?: (defined('GRAV_SETUP_PATH') ? GRAV_SETUP_PATH : 'setup.php');
if (!str_starts_with($file, '/')) {
$file = GRAV_ROOT . '/' . $file;
}
$setup = is_file($file) ? (array) include $file : [];
// Add default streams defined in beginning of the class.