/** * {@inheritdoc} */ protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $name = $input->getArgument('name'); $names = $this->configFactory->listAll(); if ($name) { if (!in_array($name, $names)) { $io->warning(sprintf($this->trans('commands.config.override.messages.invalid-name'), $name)); $name = null; } } if (!$name) { $name = $io->choiceNoList($this->trans('commands.config.override.questions.name'), $names); $input->setArgument('name', $name); } $key = $input->getArgument('key'); if (!$key) { if ($this->configStorage->exists($name)) { $configuration = $this->configStorage->read($name); } $key = $io->choiceNoList($this->trans('commands.config.override.questions.key'), array_keys($configuration)); $input->setArgument('key', $key); } $value = $input->getArgument('value'); if (!$value) { $value = $io->ask($this->trans('commands.config.override.questions.value')); $input->setArgument('value', $value); } }
/** * @param $io DrupalStyle */ private function getAllConfigurations(DrupalStyle $io) { $names = $this->configFactory->listAll(); $tableHeader = [$this->trans('commands.config.debug.arguments.name')]; $tableRows = []; foreach ($names as $name) { $tableRows[] = [$name]; } $io->table($tableHeader, $tableRows, 'compact'); }
/** * Retrieve configuration names form cache or service factory. * * @return array * All configuration names. */ private function getAllConfigNames() { if ($this->allConfig) { return $this->allConfig; } foreach ($this->configFactory->listAll() as $name) { $this->allConfig[] = $name; } return $this->allConfig; }
protected function interact(InputInterface $input, OutputInterface $output) { $io = new DrupalStyle($input, $output); $configName = $input->getArgument('config-name'); if (!$configName) { $configNames = $this->configFactory->listAll(); $configName = $io->choice('Choose a configuration', $configNames); $input->setArgument('config-name', $configName); } }