wizardresult.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @author Arthur Schiwon <blizzz@owncloud.com>
  4. * @author Bart Visscher <bartv@thisnet.nl>
  5. * @author Lukas Reschke <lukas@owncloud.com>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin McCorkell <rmccorkell@karoshi.org.uk>
  8. *
  9. * @copyright Copyright (c) 2015, ownCloud, Inc.
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\user_ldap\lib;
  26. class WizardResult {
  27. protected $changes = array();
  28. protected $options = array();
  29. protected $markedChange = false;
  30. /**
  31. * @param string $key
  32. * @param mixed $value
  33. */
  34. public function addChange($key, $value) {
  35. $this->changes[$key] = $value;
  36. }
  37. /**
  38. *
  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 = array($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 = array();
  64. $result['changes'] = $this->changes;
  65. if(count($this->options) > 0) {
  66. $result['options'] = $this->options;
  67. }
  68. return $result;
  69. }
  70. }