Skip to content
Snippets Groups Projects
Commit 1cbe4976 authored by Christoph Wurst's avatar Christoph Wurst Committed by GitHub
Browse files

Merge pull request #449 from nextcloud/refactor/iaccount-serialization

Use JsonSerializable::jsonSerialize instead of a custom method
parents dfb0b20c ca072952
No related branches found
No related tags found
No related merge requests found
......@@ -354,7 +354,7 @@ class Account implements IAccount {
* @return array
*/
public function jsonSerialize() {
throw new Exception('Not implemented');
return $this->account->toJson();
}
/**
......@@ -732,10 +732,6 @@ class Account implements IAccount {
}
/**
* @return array
*/
public function getConfiguration() {
return $this->account->toJson();
}
/**
......
......@@ -117,7 +117,7 @@ class AccountsController extends Controller {
$json = [];
foreach ($mailAccounts as $mailAccount) {
$conf = $mailAccount->getConfiguration();
$conf = $mailAccount->jsonSerialize();
$conf['aliases'] = $this->aliasesService->findAll($conf['accountId'], $this->currentUserId);
$json[] = $conf;
}
......@@ -134,7 +134,7 @@ class AccountsController extends Controller {
try {
$account = $this->accountService->find($this->currentUserId, $accountId);
return new JSONResponse($account->getConfiguration());
return new JSONResponse($account->jsonSerialize());
} catch (DoesNotExistException $e) {
return new JSONResponse([], 404);
}
......
......@@ -87,7 +87,7 @@ class PageController extends Controller {
$accountsJson = [];
foreach ($mailAccounts as $mailAccount) {
$conf = $mailAccount->getConfiguration();
$conf = $mailAccount->jsonSerialize();
$conf['aliases'] = $this->aliasesService->findAll($conf['accountId'], $this->currentUserId);
$accountsJson[] = $conf;
}
......
......@@ -25,11 +25,6 @@ use JsonSerializable;
interface IAccount extends JsonSerializable {
/**
* @return array
*/
public function getConfiguration();
/**
* @param $folderId
* @return IMailbox
......
......@@ -55,21 +55,12 @@ class UnifiedAccount implements IAccount {
$this->l10n = $l10n;
}
/**
* @return array
*/
public function getConfiguration() {
return [
'accountId' => UnifiedAccount::ID,
];
}
/**
* @return array
*/
public function jsonSerialize() {
return [
'id' => UnifiedAccount::ID,
'accountId' => UnifiedAccount::ID,
'email' => '',
'folders' => [$this->buildInbox()],
'specialFolders' => [],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment