1
0

WizardResult.php 1.9 KB

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