mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 23:23:52 +08: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:
parent
acb92282a5
commit
af86795ed1
|
@ -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',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user