1
0

DeleteConfig.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\User_LDAP\Command;
  8. use OCA\User_LDAP\Helper;
  9. use Symfony\Component\Console\Command\Command;
  10. use Symfony\Component\Console\Input\InputArgument;
  11. use Symfony\Component\Console\Input\InputInterface;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class DeleteConfig extends Command {
  14. public function __construct(
  15. protected Helper $helper,
  16. ) {
  17. parent::__construct();
  18. }
  19. protected function configure(): void {
  20. $this
  21. ->setName('ldap:delete-config')
  22. ->setDescription('deletes an existing LDAP configuration')
  23. ->addArgument(
  24. 'configID',
  25. InputArgument::REQUIRED,
  26. 'the configuration ID'
  27. )
  28. ;
  29. }
  30. protected function execute(InputInterface $input, OutputInterface $output): int {
  31. $configPrefix = $input->getArgument('configID');
  32. $success = $this->helper->deleteServerConfiguration($configPrefix);
  33. if (!$success) {
  34. $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
  35. return self::FAILURE;
  36. }
  37. $output->writeln("Deleted configuration with configID '{$configPrefix}'");
  38. return self::SUCCESS;
  39. }
  40. }