DeleteConfig.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. /** @var \OCA\User_LDAP\Helper */
  33. protected $helper;
  34. /**
  35. * @param Helper $helper
  36. */
  37. public function __construct(Helper $helper) {
  38. $this->helper = $helper;
  39. parent::__construct();
  40. }
  41. protected function configure() {
  42. $this
  43. ->setName('ldap:delete-config')
  44. ->setDescription('deletes an existing LDAP configuration')
  45. ->addArgument(
  46. 'configID',
  47. InputArgument::REQUIRED,
  48. 'the configuration ID'
  49. )
  50. ;
  51. }
  52. protected function execute(InputInterface $input, OutputInterface $output): int {
  53. $configPrefix = $input->getArgument('configID');
  54. $success = $this->helper->deleteServerConfiguration($configPrefix);
  55. if ($success) {
  56. $output->writeln("Deleted configuration with configID '{$configPrefix}'");
  57. return 0;
  58. } else {
  59. $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
  60. return 1;
  61. }
  62. }
  63. }