|
27 | 27 | namespace OCA\Settings\UserMigration; |
28 | 28 |
|
29 | 29 | use InvalidArgumentException; |
30 | | -use OC\Accounts\AccountProperty; |
31 | | -use OC\Accounts\AccountPropertyCollection; |
32 | 30 | use OC\Accounts\TAccountsHelper; |
33 | 31 | use OC\NotSquareException; |
34 | 32 | use OCP\Accounts\IAccountManager; |
@@ -97,24 +95,10 @@ public function import(IUser $user, IImportSource $importSource, OutputInterface |
97 | 95 |
|
98 | 96 | $account = $this->accountManager->getAccount($user); |
99 | 97 |
|
100 | | - /** @var array<string, array> $data */ |
| 98 | + /** @var array<string, array<string, string>>|array<string, array<int, array<string, string>>> $data */ |
101 | 99 | $data = json_decode($importSource->getFileContents(AccountMigrator::EXPORT_ACCOUNT_FILE), true, 512, JSON_THROW_ON_ERROR); |
102 | 100 |
|
103 | | - foreach ($data as $propertyName => $propertyData) { |
104 | | - if ($this->isCollection($propertyName)) { |
105 | | - $collection = new AccountPropertyCollection($propertyName); |
106 | | - /** @var array<int, array{name: string, value: string, scope: string, verified: string, verificationData: string}> $collectionData */ |
107 | | - $collectionData = $propertyData[$propertyName]; |
108 | | - foreach ($collectionData as ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData]) { |
109 | | - $collection->addProperty(new AccountProperty($collection->getName(), $value, $scope, $verified, $verificationData)); |
110 | | - } |
111 | | - $account->setPropertyCollection($collection); |
112 | | - } else { |
113 | | - /** @var array{name: string, value: string, scope: string, verified: string, verificationData: string} $propertyData */ |
114 | | - ['value' => $value, 'scope' => $scope, 'verified' => $verified, 'verificationData' => $verificationData] = $propertyData; |
115 | | - $account->setProperty($propertyName, $value, $scope, $verified, $verificationData); |
116 | | - } |
117 | | - } |
| 101 | + $account->setAllPropertiesFromJson($data); |
118 | 102 |
|
119 | 103 | try { |
120 | 104 | $this->accountManager->updateAccount($account); |
|
0 commit comments