diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-01-18 21:13:23 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-01-18 21:13:23 +0100 |
commit | 689df9a843dd0505088143de039af775a3f92612 (patch) | |
tree | 717a7eb2baa8f4c7f8e6870d2753fe9f03d77929 /apps/user_ldap/lib/Command/CreateEmptyConfig.php | |
parent | 012708e1badebe5dab6260c2e9edb521d5dbfee0 (diff) | |
download | nextcloud-server-689df9a843dd0505088143de039af775a3f92612.tar.gz nextcloud-server-689df9a843dd0505088143de039af775a3f92612.zip |
LDAP OCS Api for create config
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/user_ldap/lib/Command/CreateEmptyConfig.php')
-rw-r--r-- | apps/user_ldap/lib/Command/CreateEmptyConfig.php | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/apps/user_ldap/lib/Command/CreateEmptyConfig.php b/apps/user_ldap/lib/Command/CreateEmptyConfig.php index 28d3a1d8bff..38d3192058c 100644 --- a/apps/user_ldap/lib/Command/CreateEmptyConfig.php +++ b/apps/user_ldap/lib/Command/CreateEmptyConfig.php @@ -29,6 +29,7 @@ use OCA\User_LDAP\Configuration; use OCA\User_LDAP\Helper; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class CreateEmptyConfig extends Command { @@ -47,29 +48,24 @@ class CreateEmptyConfig extends Command { $this ->setName('ldap:create-empty-config') ->setDescription('creates an empty LDAP configuration') + ->addOption( + 'only-print-prefix', + 'p', + InputOption::VALUE_NONE, + 'outputs only the prefix' + ) ; } protected function execute(InputInterface $input, OutputInterface $output) { - $configPrefix = $this->getNewConfigurationPrefix(); - $output->writeln("Created new configuration with configID '{$configPrefix}'"); - + $configPrefix = $this->helper->getNextServerConfigurationPrefix(); $configHolder = new Configuration($configPrefix); $configHolder->saveConfiguration(); - } - protected function getNewConfigurationPrefix() { - $serverConnections = $this->helper->getServerConfigurationPrefixes(); - - // first connection uses no prefix - if(sizeof($serverConnections) == 0) { - return ''; + $prose = ''; + if(!$input->getOption('only-print-prefix')) { + $prose = 'Created new configuration with configID '; } - - sort($serverConnections); - $lastKey = array_pop($serverConnections); - $lastNumber = intval(str_replace('s', '', $lastKey)); - $nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT); - return $nextPrefix; + $output->writeln($prose . "{$configPrefix}"); } } |