mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 13:36:10 +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
|
||||
if (file_exists($configurationFile)) {
|
||||
// Parse YAML
|
||||
$configuration = Yaml::parse(file_get_contents($configurationFile));
|
||||
$configurationFileContents = 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
|
||||
$this->baseUrl = isset($configuration['baseUrl']) ? rtrim($configuration['baseUrl'], '/') : null;
|
||||
|
|
|
@ -69,7 +69,7 @@ class InstallCommand extends AbstractCommand
|
|||
'file',
|
||||
'f',
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'Use external configuration file in YAML format'
|
||||
'Use external configuration file in JSON or YAML format'
|
||||
)
|
||||
->addOption(
|
||||
'config',
|
||||
|
|
Loading…
Reference in New Issue
Block a user