Refactoring
This commit is contained in:
parent
87928dbbc9
commit
23127dd193
4 changed files with 58 additions and 36 deletions
|
|
@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue