Skip to content

Commit

Permalink
[Settings:set] update to check first config available stating in curr…
Browse files Browse the repository at this point in the history
…ent site first, added french to documentation
  • Loading branch information
enzolutions committed May 9, 2018
1 parent eb59489 commit c62582c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/chain/update-gitbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ commands:
- views
- features
- command: 'develop:translation:sync'
{% set languages = ['en', 'ca', 'es', 'hi', 'hu', 'ja', 'mr', 'pt-br', 'ro', 'ru', 'vn' , 'zh-hans'] %}
{% set languages = ['en', 'ca', 'es', 'fr', 'hi', 'hu', 'ja', 'mr', 'pt-br', 'ro', 'ru', 'vn' , 'zh-hans'] %}
{% for language in languages %}
- command: settings:set
arguments:
Expand Down
14 changes: 6 additions & 8 deletions src/Command/Settings/SetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
$settingName = $input->getArgument('name');
$settingValue = $input->getArgument('value');

$userConfigFile = sprintf(
'%s/.console/config.yml',
$this->configurationManager->getHomeDirectory()
);
// get configuration file
$configFile = $this->configurationManager->getConfigurationFile();

if (!file_exists($userConfigFile)) {
if (!file_exists($configFile)) {
$this->getIo()->error(
sprintf(
$this->trans('commands.settings.set.messages.missing-file'),
$userConfigFile
$configFile
)
);
return 1;
}

try {
$userConfigFileParsed = $parser->parse(
file_get_contents($userConfigFile)
file_get_contents($configFile)
);
} catch (\Exception $e) {
$this->getIo()->error(
Expand Down Expand Up @@ -151,7 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

try {
file_put_contents($userConfigFile, $userConfigFileDump);
file_put_contents($configFile, $userConfigFileDump);
} catch (\Exception $e) {
$this->getIo()->error(
[
Expand Down
20 changes: 20 additions & 0 deletions src/Utils/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function loadConfiguration($directory)
true
);
}

$input = new ArgvInput();
$root = $input->getParameterOption(['--root']);
if ($root && is_dir($root)) {
Expand Down Expand Up @@ -285,20 +286,39 @@ public function getConfigurationDirectories($includeVendorCore = false)
return [];
}

public function getConfigurationFile()
{
foreach (array_reverse($this->configurationDirectories) as $directory) {
$file = sprintf(
'%s/config.yml',
$directory
);

if (file_exists($file)) {
return $file;
}
}

return null;
}

private function addConfigurationFilesByDirectory(
$directory,
$addDirectory = false
) {

if ($addDirectory) {
$this->configurationDirectories[] = $directory;
}

$configurationFiles = [
'config' => 'config.yml',
'drush' => 'drush.yml',
'aliases' => 'aliases.yml',
'mappings' => 'mappings.yml',
'defaults' => 'defaults.yml',
];

foreach ($configurationFiles as $key => $file) {
$configFile = $directory.$file;
if (is_file($configFile)) {
Expand Down

0 comments on commit c62582c

Please sign in to comment.