1
0

WizardResult.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019-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;
  8. class WizardResult {
  9. protected $changes = [];
  10. protected $options = [];
  11. protected $markedChange = false;
  12. /**
  13. * @param string $key
  14. * @param mixed $value
  15. */
  16. public function addChange($key, $value) {
  17. $this->changes[$key] = $value;
  18. }
  19. public function markChange() {
  20. $this->markedChange = true;
  21. }
  22. /**
  23. * @param string $key
  24. * @param array|string $values
  25. */
  26. public function addOptions($key, $values) {
  27. if (!is_array($values)) {
  28. $values = [$values];
  29. }
  30. $this->options[$key] = $values;
  31. }
  32. /**
  33. * @return bool
  34. */
  35. public function hasChanges() {
  36. return (count($this->changes) > 0 || $this->markedChange);
  37. }
  38. /**
  39. * @return array
  40. */
  41. public function getResultArray() {
  42. $result = [];
  43. $result['changes'] = $this->changes;
  44. if (count($this->options) > 0) {
  45. $result['options'] = $this->options;
  46. }
  47. return $result;
  48. }
  49. }