Esempio n. 1
0
 /**
  * {@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);
     }
 }
Esempio n. 2
0
 /**
  * Test listAll static cache.
  */
 public function testListAllStaticCache()
 {
     $prefix = __FUNCTION__;
     $storage = $this->getMock('Drupal\\Core\\Config\\StorageInterface');
     $response = array("{$prefix}." . $this->randomMachineName(), "{$prefix}." . $this->randomMachineName());
     $storage->expects($this->once())->method('listAll')->with($prefix)->will($this->returnValue($response));
     $cache = new NullBackend(__FUNCTION__);
     $cachedStorage = new CachedStorage($storage, $cache);
     $this->assertEquals($response, $cachedStorage->listAll($prefix));
     $this->assertEquals($response, $cachedStorage->listAll($prefix));
 }
Esempio n. 3
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));
     }
 }
 protected function getConfigNames($config_type)
 {
     // For a given entity type, load all entities.
     if ($config_type && $config_type !== 'system.simple') {
         $entity_storage = $this->entityManager->getStorage($config_type);
         foreach ($entity_storage->loadMultiple() as $entity) {
             $entity_id = $entity->id();
             $label = $entity->label() ?: $entity_id;
             $names[$entity_id] = $label;
         }
     } else {
         // Gather the config entity prefixes.
         $config_prefixes = array_map(function ($definition) {
             return $definition->getConfigPrefix() . '.';
         }, $this->definitions);
         // Find all config, and then filter our anything matching a config prefix.
         $names = $this->configStorage->listAll();
         $names = array_combine($names, $names);
         foreach ($names as $config_name) {
             foreach ($config_prefixes as $config_prefix) {
                 if (strpos($config_name, $config_prefix) === 0) {
                     unset($names[$config_name]);
                 }
             }
         }
     }
     return $names;
 }
Esempio n. 5
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;
 }
Esempio n. 6
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));
 }