Refactoring

This commit is contained in:
Lexi / Zoe 2021-09-12 22:16:06 +02:00
parent 87928dbbc9
commit 23127dd193
Signed by: binaryDiv
GPG key ID: F8D4956E224DA232
4 changed files with 58 additions and 36 deletions

View file

@ -61,6 +61,18 @@ class AccountHandler
// -- /accounts/{id}/edit - Edit account data
public function getAccountDataForEdit(int $accountId): array
{
// Get account data from database
$account = $this->accountRepository->fetchAccountById($accountId);
return [
'id' => $accountId,
'accountUsername' => $account->getUsername(),
'account' => $account,
];
}
public function editAccountData(int $accountId, AccountEditData $editData): void
{
// Check if account exists
@ -144,4 +156,22 @@ class AccountHandler
// Commit database transaction
$this->accountRepository->commitTransaction();
}
// -- /accounts/{id}/delete - Delete account
public function getAccountDataForDelete(int $accountId): array
{
// Get account data from database
$account = $this->accountRepository->fetchAccountById($accountId);
// Get list of aliases for this account
$aliases = $this->aliasRepository->fetchAliasesForUserId($accountId);
return [
'id' => $accountId,
'accountUsername' => $account->getUsername(),
'aliases' => $aliases,
];
}
}