mirror of
https://github.com/flarum/core.git
synced 2025-08-01 14:10:37 +02:00
Allow JSON to be used for Install Command (#1193)
* Allow JSON to be used for Install Command * Return configuration as array instead of object. * Update InstallCommand.php
This commit is contained in:
@@ -33,8 +33,15 @@ class FileDataProvider implements DataProviderInterface
|
|||||||
|
|
||||||
// Check if file exists before parsing content
|
// Check if file exists before parsing content
|
||||||
if (file_exists($configurationFile)) {
|
if (file_exists($configurationFile)) {
|
||||||
// Parse YAML
|
$configurationFileContents = file_get_contents($configurationFile);
|
||||||
$configuration = Yaml::parse(file_get_contents($configurationFile));
|
// Try parsing JSON
|
||||||
|
if (($json = json_decode($configurationFileContents, true)) !== null) {
|
||||||
|
//Use JSON if Valid
|
||||||
|
$configuration = $json;
|
||||||
|
} else {
|
||||||
|
//Else use YAML
|
||||||
|
$configuration = Yaml::parse($configurationFileContents);
|
||||||
|
}
|
||||||
|
|
||||||
// Define configuration variables
|
// Define configuration variables
|
||||||
$this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null;
|
$this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null;
|
||||||
|
@@ -69,7 +69,7 @@ class InstallCommand extends AbstractCommand
|
|||||||
'file',
|
'file',
|
||||||
'f',
|
'f',
|
||||||
InputOption::VALUE_REQUIRED,
|
InputOption::VALUE_REQUIRED,
|
||||||
'Use external configuration file in YAML format'
|
'Use external configuration file in JSON or YAML format'
|
||||||
)
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'config',
|
'config',
|
||||||
|
Reference in New Issue
Block a user