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