* If an option is defined as a command parameter, this will be used
* Otherwise, if an option is defined in the configuration file, this will
be used.
* Otherwise, default values will be used
public loadConfigValues ( string $commandName, array $configValues, array $commandValues = [], array $defaultValues = [] ) : array | ||
$commandName | string | Command called |
$configValues | array | Config values |
$commandValues | array | Values defined in command |
$defaultValues | array | Default values to use if these are not defined |
Результат | array | $usableValues Usable values |
/** * Test load config values. * * @dataProvider dataLoadConfigValues */ public function testLoadConfigValues($configValues, $commandValues, $defaultValues, $usableValues) { $configLoader = new ConfigLoader(); $this->assertEquals($usableValues, $configLoader->loadConfigValues(UseSortCommand::COMMAND_NAME, $configValues, $commandValues, $defaultValues)); }
/** * Load config * * @param InputInterface $input Input * * @return array Config array */ private function getUsableConfig(InputInterface $input) { $configLoader = new ConfigLoader(); $configFinder = new ConfigFinder(); /** * This section is just for finding the right values to work with in * this execution. * * $options array will have, after this block, all these values */ $configPath = rtrim($input->getOption('config'), DIRECTORY_SEPARATOR); return $configLoader->loadConfigValues(self::COMMAND_NAME, $configFinder->findConfigFile($configPath), ['group' => $input->getOption('group'), 'group-type' => $input->getOption('group-type'), 'group-skip-empty' => $input->getOption('group-skip-empty'), 'sort-type' => $input->getOption('sort-type'), 'sort-direction' => $input->getOption('sort-direction')], ['group' => ['_main'], 'group-type' => UseSorter::GROUP_TYPE_EACH, 'group-skip-empty' => false, 'sort-type' => UseSorter::SORT_TYPE_ALPHABETIC, 'sort-direction' => UseSorter::SORT_DIRECTION_ASC]); }