Beispiel #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configNames = $input->getArgument('name');
     $configName = $configNames[0];
     if (sizeof($configNames) > 1) {
         if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
             $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
             return 1;
         }
         $value = $this->systemConfig->getValue($configName);
         try {
             $value = $this->removeSubValue(array_slice($configNames, 1), $value, $input->hasParameterOption('--error-if-not-exists'));
         } catch (\UnexpectedValueException $e) {
             $output->writeln('<error>System config ' . implode(' => ', $configNames) . ' could not be deleted because it did not exist</error>');
             return 1;
         }
         $this->systemConfig->setValue($configName, $value);
         $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' deleted</info>');
         return 0;
     } else {
         if ($input->hasParameterOption('--error-if-not-exists') && !in_array($configName, $this->systemConfig->getKeys())) {
             $output->writeln('<error>System config ' . $configName . ' could not be deleted because it did not exist</error>');
             return 1;
         }
         $this->systemConfig->deleteValue($configName);
         $output->writeln('<info>System config value ' . $configName . ' deleted</info>');
         return 0;
     }
 }
Beispiel #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configName = $input->getArgument('name');
     if (!in_array($configName, $this->systemConfig->getKeys()) && $input->hasParameterOption('--update-only')) {
         $output->writeln('<comment>Config value ' . $configName . ' not updated, as it has not been set before.</comment>');
         return 1;
     }
     $configValue = $input->getOption('value');
     $this->systemConfig->setValue($configName, $configValue);
     $output->writeln('<info>System config value ' . $configName . ' set to ' . $configValue . '</info>');
     return 0;
 }
Beispiel #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configNames = $input->getArgument('name');
     $configName = $configNames[0];
     $configValue = $this->castValue($input->getOption('value'), $input->getOption('type'));
     $updateOnly = $input->getOption('update-only');
     if (sizeof($configNames) > 1) {
         $existingValue = $this->systemConfig->getValue($configName);
         $newValue = $this->mergeArrayValue(array_slice($configNames, 1), $existingValue, $configValue['value'], $updateOnly);
         $this->systemConfig->setValue($configName, $newValue);
     } else {
         if ($updateOnly && !in_array($configName, $this->systemConfig->getKeys(), true)) {
             throw new \UnexpectedValueException('Config parameter does not exist');
         }
         $this->systemConfig->setValue($configName, $configValue['value']);
     }
     $output->writeln('<info>System config value ' . implode(' => ', $configNames) . ' set to ' . $configValue['readable-value'] . '</info>');
     return 0;
 }
Beispiel #4
0
 /**
  * Sets a new system wide value
  *
  * @param string $key the key of the value, under which will be saved
  * @param mixed $value the value that should be stored
  */
 public function setSystemValue($key, $value)
 {
     $this->systemConfig->setValue($key, $value);
 }