/**
  * {@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);
     }
 }
Example #2
0
 /**
  * @param $io             DrupalStyle
  * @param $config_name    String
  */
 private function getConfigurationByName(DrupalStyle $io, $config_name)
 {
     if ($this->configStorage->exists($config_name)) {
         $tableHeader = [$config_name];
         $configuration = $this->configStorage->read($config_name);
         $configurationEncoded = Yaml::encode($configuration);
         $tableRows = [];
         $tableRows[] = [$configurationEncoded];
         $io->table($tableHeader, $tableRows, 'compact');
     } else {
         $io->error(sprintf($this->trans('commands.config.debug.errors.not-exists'), $config_name));
     }
 }
Example #3
0
 /**
  * @param $config_name String
  *
  * @return array
  */
 protected function getYamlConfig($config_name)
 {
     if ($this->configStorage->exists($config_name)) {
         $configuration = $this->configStorage->read($config_name);
         $configurationEncoded = Yaml::encode($configuration);
     }
     return $configurationEncoded;
 }
Example #4
0
 /**
  * Test file storage on a cache hit in CachedStorage::read().
  */
 public function testReadNonExistentFileCached()
 {
     $name = 'config.does_not_exist';
     $cache = new MemoryBackend(__FUNCTION__);
     $cache->set($name, FALSE);
     $storage = $this->getMock('Drupal\\Core\\Config\\StorageInterface');
     $storage->expects($this->never())->method('read');
     $this->cacheFactory->expects($this->once())->method('get')->with('config')->will($this->returnValue($cache));
     $cachedStorage = new CachedStorage($storage, $this->cacheFactory);
     $this->assertFalse($cachedStorage->read($name));
 }