2014-09-29 03:17:53 +00:00
|
|
|
<?php
|
2024-05-29 09:32:54 +00:00
|
|
|
|
2014-09-29 03:17:53 +00:00
|
|
|
/**
|
2024-05-29 09:32:54 +00:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-09-29 03:17:53 +00:00
|
|
|
*/
|
2016-05-12 07:59:29 +00:00
|
|
|
namespace OCA\User_LDAP\Command;
|
2014-09-29 03:17:53 +00:00
|
|
|
|
2016-09-09 14:52:10 +00:00
|
|
|
use OCA\User_LDAP\Configuration;
|
|
|
|
use OCA\User_LDAP\Helper;
|
2014-09-29 03:17:53 +00:00
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
2017-01-18 20:13:23 +00:00
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
2014-09-29 03:17:53 +00:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class CreateEmptyConfig extends Command {
|
2024-01-24 07:38:56 +00:00
|
|
|
public function __construct(
|
|
|
|
protected Helper $helper,
|
|
|
|
) {
|
2015-03-23 14:17:14 +00:00
|
|
|
parent::__construct();
|
|
|
|
}
|
2014-09-29 03:17:53 +00:00
|
|
|
|
2024-01-24 07:38:56 +00:00
|
|
|
protected function configure(): void {
|
2014-09-29 03:17:53 +00:00
|
|
|
$this
|
|
|
|
->setName('ldap:create-empty-config')
|
|
|
|
->setDescription('creates an empty LDAP configuration')
|
2017-01-18 20:13:23 +00:00
|
|
|
->addOption(
|
|
|
|
'only-print-prefix',
|
|
|
|
'p',
|
|
|
|
InputOption::VALUE_NONE,
|
|
|
|
'outputs only the prefix'
|
|
|
|
)
|
2014-09-29 03:17:53 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2020-06-26 13:12:11 +00:00
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
2017-01-18 20:13:23 +00:00
|
|
|
$configPrefix = $this->helper->getNextServerConfigurationPrefix();
|
2014-09-29 03:17:53 +00:00
|
|
|
$configHolder = new Configuration($configPrefix);
|
2022-03-22 13:53:37 +00:00
|
|
|
$configHolder->ldapConfigurationActive = false;
|
2014-09-29 03:17:53 +00:00
|
|
|
$configHolder->saveConfiguration();
|
|
|
|
|
2017-01-18 20:13:23 +00:00
|
|
|
$prose = '';
|
|
|
|
if (!$input->getOption('only-print-prefix')) {
|
|
|
|
$prose = 'Created new configuration with configID ';
|
2014-09-29 03:17:53 +00:00
|
|
|
}
|
2017-01-18 20:13:23 +00:00
|
|
|
$output->writeln($prose . "{$configPrefix}");
|
2024-01-24 07:38:56 +00:00
|
|
|
return self::SUCCESS;
|
2014-09-29 03:17:53 +00:00
|
|
|
}
|
|
|
|
}
|