1
0

DeleteConfig.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Martin Konrad <info@martin-konrad.net>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\User_LDAP\Command;
  26. use OCA\User_LDAP\Helper;
  27. use Symfony\Component\Console\Command\Command;
  28. use Symfony\Component\Console\Input\InputArgument;
  29. use Symfony\Component\Console\Input\InputInterface;
  30. use Symfony\Component\Console\Output\OutputInterface;
  31. class DeleteConfig extends Command {
  32. public function __construct(
  33. protected Helper $helper,
  34. ) {
  35. parent::__construct();
  36. }
  37. protected function configure(): void {
  38. $this
  39. ->setName('ldap:delete-config')
  40. ->setDescription('deletes an existing LDAP configuration')
  41. ->addArgument(
  42. 'configID',
  43. InputArgument::REQUIRED,
  44. 'the configuration ID'
  45. )
  46. ;
  47. }
  48. protected function execute(InputInterface $input, OutputInterface $output): int {
  49. $configPrefix = $input->getArgument('configID');
  50. $success = $this->helper->deleteServerConfiguration($configPrefix);
  51. if (!$success) {
  52. $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
  53. return self::FAILURE;
  54. }
  55. $output->writeln("Deleted configuration with configID '{$configPrefix}'");
  56. return self::SUCCESS;
  57. }
  58. }