aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorPytal <24800714+Pytal@users.noreply.github.com>2022-03-17 15:22:41 -0700
committerGitHub <noreply@github.com>2022-03-17 15:22:41 -0700
commit3f190d9fe6355a837ebc9b56c3211e9e7ac6d396 (patch)
tree31db15c27346212872001a1a7bc9857fb656ccc3 /lib/private
parent6fae5983904b3f8c0435923db297e6feccf9a6e9 (diff)
parentc505bb144954821a86a57a496d2a31d9f6f6cb1f (diff)
downloadnextcloud-server-3f190d9fe6355a837ebc9b56c3211e9e7ac6d396.tar.gz
nextcloud-server-3f190d9fe6355a837ebc9b56c3211e9e7ac6d396.zip
Merge pull request #31488 from nextcloud/enh/account-set-all-properties
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Accounts/Account.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/private/Accounts/Account.php b/lib/private/Accounts/Account.php
index 7d36af561ce..d3287b219d0 100644
--- a/lib/private/Accounts/Account.php
+++ b/lib/private/Accounts/Account.php
@@ -72,6 +72,28 @@ class Account implements IAccount {
});
}
+ public function setAllPropertiesFromJson(array $properties): IAccount {
+ foreach ($properties as $propertyName => $propertyObject) {
+ if ($this->isCollection($propertyName)) {
+ $collection = new AccountPropertyCollection($propertyName);
+ /** @var array<int, IAccountProperty> $collectionProperties */
+ $collectionProperties = [];
+ /** @var array<int, array<string, string>> $propertyObject */
+ foreach ($propertyObject as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) {
+ $collectionProperties[] = new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData);
+ }
+ $collection->setProperties($collectionProperties);
+ $this->setPropertyCollection($collection);
+ } else {
+ /** @var array<string, string> $propertyObject */
+ ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyObject;
+ $this->setProperty($propertyName, $value, $scope, $verified, $verificationData);
+ }
+ }
+
+ return $this;
+ }
+
public function getAllProperties(): Generator {
foreach ($this->properties as $propertyObject) {
if ($propertyObject instanceof IAccountProperty) {