Arkade\S3\Console\Command\ConfigSetCommand::execute PHP Method

execute() protected method

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('region') && !$input->getOption('bucket') && !$input->getOption('secret-key') && !$input->getOption('access-key-id')) {
            $output->writeln($this->getSynopsis());
            return;
        }
        $errors = $this->validate($input);
        if ($errors) {
            $output->writeln('<error>' . implode('</error>' . PHP_EOL . '<error>', $errors) . '</error>');
            return;
        }
        $this->state->setAreaCode('adminhtml');
        $config = $this->configFactory->create();
        if (!empty($input->getOption('access-key-id'))) {
            $config->setDataByPath('arkade_s3/general/access_key', $input->getOption('access-key-id'));
            $config->save();
        }
        if (!empty($input->getOption('secret-key'))) {
            $config->setDataByPath('arkade_s3/general/secret_key', $input->getOption('secret-key'));
            $config->save();
        }
        if (!empty($input->getOption('bucket'))) {
            $config->setDataByPath('arkade_s3/general/bucket', $input->getOption('bucket'));
            $config->save();
        }
        if (!empty($input->getOption('region'))) {
            $config->setDataByPath('arkade_s3/general/region', $input->getOption('region'));
            $config->save();
        }
        $output->writeln('<info>You have successfully updated your S3 credentials.</info>');
    }