SetDefaultProvider.php 911 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\User_LDAP\Migration;
  8. use OCA\User_LDAP\Helper;
  9. use OCA\User_LDAP\LDAPProviderFactory;
  10. use OCP\IConfig;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\IRepairStep;
  13. class SetDefaultProvider implements IRepairStep {
  14. /** @var IConfig */
  15. private $config;
  16. /** @var Helper */
  17. private $helper;
  18. public function __construct(IConfig $config,
  19. Helper $helper) {
  20. $this->config = $config;
  21. $this->helper = $helper;
  22. }
  23. public function getName(): string {
  24. return 'Set default LDAP provider';
  25. }
  26. public function run(IOutput $output): void {
  27. $current = $this->config->getSystemValue('ldapProviderFactory', null);
  28. if ($current === null) {
  29. $this->config->setSystemValue('ldapProviderFactory', LDAPProviderFactory::class);
  30. }
  31. }
  32. }