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:
Davis 2017-05-26 23:48:09 -05:00 committed by Toby Zerner
parent acb92282a5
commit af86795ed1
2 changed files with 10 additions and 3 deletions

View File

@ -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;

View File

@ -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',