Skip to content
Snippets Groups Projects
Select Git revision
  • 80a8a75ea6070650b86d4f6aa008bfb65b22f513
  • main default protected
  • 5.5 protected
  • atlantis
  • 5.3 protected
  • 5.0 protected
  • issue-23
  • issue8-seat-logging-and-export
  • ticket-216
  • tickets-215-216-241-242
10 results

ErrorHandler.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SetConfigValue.php 1.25 KiB
    <?php
    
    namespace Studip\Cli\Commands\Config;
    
    use Symfony\Component\Console\Command\Command;
    use Symfony\Component\Console\Input\InputArgument;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    use Symfony\Component\Console\Helper\Table;
    
    class SetConfigValue extends Command
    {
        protected static $defaultName = 'config:set';
    
        protected function configure(): void
        {
            $this->setDescription('Set value of a Stud.IP configuration key.');
            $this->setHelp('This command will set the value of a Stud.IP configuration key.');
            $this->addArgument('config-key', InputArgument::REQUIRED, 'Key of the configuration.');
            $this->addArgument('config-value', InputArgument::REQUIRED, 'Value of the configuration.');
        }
    
        protected function execute(InputInterface $input, OutputInterface $output): int
        {
            $configKey = $input->getArgument('config-key');
            $configValue = $input->getArgument('config-value');
            $metadata = \Config::get()->getMetadata($configKey);
            if (!$metadata) {
                throw new \RuntimeException("Unknown config key '{$configKey}");
            }
    
            \Config::get()->store($configKey, $configValue);
    
            return Command::SUCCESS;
        }
    }