Esempio n. 1
0
 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  * @return null|int null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configNames = $input->getArgument('name');
     $configName = array_shift($configNames);
     $defaultValue = $input->getOption('default-value');
     if (!in_array($configName, $this->systemConfig->getKeys()) && !$input->hasParameterOption('--default-value')) {
         return 1;
     }
     if (!in_array($configName, $this->systemConfig->getKeys())) {
         $configValue = $defaultValue;
     } else {
         $configValue = $this->systemConfig->getValue($configName);
         if (!empty($configNames)) {
             foreach ($configNames as $configName) {
                 if (isset($configValue[$configName])) {
                     $configValue = $configValue[$configName];
                 } else {
                     if (!$input->hasParameterOption('--default-value')) {
                         return 1;
                     } else {
                         $configValue = $defaultValue;
                         break;
                     }
                 }
             }
         }
     }
     $this->writeMixedInOutputFormat($input, $output, $configValue);
     return 0;
 }
Esempio n. 2
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;
     }
 }
Esempio n. 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configName = $input->getArgument('name');
     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;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 /**
  * Get the system configs
  *
  * @param bool $noSensitiveValues
  * @return array
  */
 protected function getSystemConfigs($noSensitiveValues)
 {
     $keys = $this->systemConfig->getKeys();
     $configs = [];
     foreach ($keys as $key) {
         if ($noSensitiveValues && in_array($key, $this->sensitiveValues)) {
             continue;
         }
         $value = $this->systemConfig->getValue($key, serialize(null));
         if ($value !== 'N;') {
             $configs[$key] = $value;
         }
     }
     return $configs;
 }
Esempio n. 6
0
 /**
  * Executes the current command.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  * @return null|int null or 0 if everything went fine, or an error code
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $configName = $input->getArgument('name');
     $defaultValue = $input->getOption('default-value');
     if (!in_array($configName, $this->systemConfig->getKeys()) && !$input->hasParameterOption('--default-value')) {
         return 1;
     }
     if (!in_array($configName, $this->systemConfig->getKeys())) {
         $configValue = $defaultValue;
     } else {
         $configValue = $this->systemConfig->getValue($configName);
     }
     $this->writeMixedInOutputFormat($input, $output, $configValue);
     return 0;
 }
Esempio n. 7
0
 /**
  * Get the system configs
  *
  * @param bool $noSensitiveValues
  * @return array
  */
 protected function getSystemConfigs($noSensitiveValues)
 {
     $keys = $this->systemConfig->getKeys();
     $configs = [];
     foreach ($keys as $key) {
         $value = $this->systemConfig->getValue($key, serialize(null));
         if ($noSensitiveValues && isset($this->sensitiveValues[$key])) {
             $value = $this->removeSensitiveValue($this->sensitiveValues[$key], $value);
         }
         if ($value !== 'N;') {
             $configs[$key] = $value;
         }
     }
     return $configs;
 }
Esempio n. 8
0
 /**
  * Get the system configs
  *
  * @param bool $noSensitiveValues
  * @return array
  */
 protected function getSystemConfigs($noSensitiveValues)
 {
     $keys = $this->systemConfig->getKeys();
     $configs = [];
     foreach ($keys as $key) {
         if ($noSensitiveValues) {
             $value = $this->systemConfig->getFilteredValue($key, serialize(null));
         } else {
             $value = $this->systemConfig->getValue($key, serialize(null));
         }
         if ($value !== 'N;') {
             $configs[$key] = $value;
         }
     }
     return $configs;
 }
Esempio n. 9
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;
 }