WizardResult.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Robin McCorkell <robin@mccorkell.me.uk>
  11. * @author Roeland Jago Douma <roeland@famdouma.nl>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. namespace OCA\User_LDAP;
  29. class WizardResult {
  30. protected $changes = [];
  31. protected $options = [];
  32. protected $markedChange = false;
  33. /**
  34. * @param string $key
  35. * @param mixed $value
  36. */
  37. public function addChange($key, $value) {
  38. $this->changes[$key] = $value;
  39. }
  40. public function markChange() {
  41. $this->markedChange = true;
  42. }
  43. /**
  44. * @param string $key
  45. * @param array|string $values
  46. */
  47. public function addOptions($key, $values) {
  48. if (!is_array($values)) {
  49. $values = [$values];
  50. }
  51. $this->options[$key] = $values;
  52. }
  53. /**
  54. * @return bool
  55. */
  56. public function hasChanges() {
  57. return (count($this->changes) > 0 || $this->markedChange);
  58. }
  59. /**
  60. * @return array
  61. */
  62. public function getResultArray() {
  63. $result = [];
  64. $result['changes'] = $this->changes;
  65. if (count($this->options) > 0) {
  66. $result['options'] = $this->options;
  67. }
  68. return $result;
  69. }
  70. }