2013-09-27 12:30:59 -04:00
|
|
|
<?php
|
2024-05-29 05:32:54 -04:00
|
|
|
|
2025-10-07 04:30:15 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2013-09-27 12:30:59 -04:00
|
|
|
/**
|
2024-05-29 05:32:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-09-27 12:30:59 -04:00
|
|
|
*/
|
2025-10-07 04:30:15 -04:00
|
|
|
|
2016-05-12 10:08:46 -04:00
|
|
|
namespace OCA\User_LDAP;
|
2013-09-27 12:30:59 -04:00
|
|
|
|
|
|
|
|
class WizardResult {
|
2025-10-07 04:30:15 -04:00
|
|
|
/**
|
|
|
|
|
* @var array<string,int|string|int[]|string[]>
|
|
|
|
|
*/
|
|
|
|
|
protected array $changes = [];
|
|
|
|
|
/**
|
|
|
|
|
* @var array<string,string[]>
|
|
|
|
|
*/
|
|
|
|
|
protected array $options = [];
|
|
|
|
|
protected bool $markedChange = false;
|
2013-09-27 12:30:59 -04:00
|
|
|
|
2014-05-11 09:17:27 -04:00
|
|
|
/**
|
2025-10-07 04:30:15 -04:00
|
|
|
* @param int|string|int[]|string[] $value
|
2014-05-11 09:17:27 -04:00
|
|
|
*/
|
2025-10-07 04:30:15 -04:00
|
|
|
public function addChange(string $key, int|string|array $value): void {
|
2013-09-27 12:30:59 -04:00
|
|
|
$this->changes[$key] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2025-10-07 04:30:15 -04:00
|
|
|
public function markChange(): void {
|
2013-10-09 19:21:05 -04:00
|
|
|
$this->markedChange = true;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-14 11:39:29 -04:00
|
|
|
/**
|
2025-10-07 04:30:15 -04:00
|
|
|
* @param string|string[] $values
|
2014-04-14 11:39:29 -04:00
|
|
|
*/
|
2025-10-07 04:30:15 -04:00
|
|
|
public function addOptions(string $key, string|array $values): void {
|
2013-10-04 10:33:37 -04:00
|
|
|
if (!is_array($values)) {
|
2020-03-26 04:30:18 -04:00
|
|
|
$values = [$values];
|
2013-10-04 10:33:37 -04:00
|
|
|
}
|
|
|
|
|
$this->options[$key] = $values;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-07 04:30:15 -04:00
|
|
|
public function hasChanges(): bool {
|
2013-10-09 19:21:05 -04:00
|
|
|
return (count($this->changes) > 0 || $this->markedChange);
|
2013-09-27 12:30:59 -04:00
|
|
|
}
|
|
|
|
|
|
2014-05-11 09:17:27 -04:00
|
|
|
/**
|
2025-10-07 04:30:15 -04:00
|
|
|
* @return array{changes:array<string,int|string|int[]|string[]>,options?:array<string,string[]>}
|
2014-05-11 09:17:27 -04:00
|
|
|
*/
|
2025-10-07 04:30:15 -04:00
|
|
|
public function getResultArray(): array {
|
2020-03-26 04:30:18 -04:00
|
|
|
$result = [];
|
2013-09-27 12:30:59 -04:00
|
|
|
$result['changes'] = $this->changes;
|
2013-10-04 10:33:37 -04:00
|
|
|
if (count($this->options) > 0) {
|
|
|
|
|
$result['options'] = $this->options;
|
|
|
|
|
}
|
2013-09-27 12:30:59 -04:00
|
|
|
return $result;
|
|
|
|
|
}
|
2014-05-13 07:29:25 -04:00
|
|
|
}
|