From 39536551ee9905528e599d5a1cb822a6dc962018 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 3 Jul 2017 22:43:57 +0200 Subject: [PATCH 1/2] Tested method pull out More pull out should be done and maybe moved to a new controller for SOLID! --- Controller.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Controller.php b/Controller.php index 206c5cb..e493463 100644 --- a/Controller.php +++ b/Controller.php @@ -388,6 +388,14 @@ class Controller extends ModuleAbstract implements WebInterface return; } + $account = createAccountModel($request); + AccountMapper::create($account); + + $response->set('account', $account->jsonSerialize()); + } + + private function createAccountModel($request) : Account + { $account = new Account(); $account->setStatus($request->getData('status')); $account->setType($request->getData('type')); @@ -397,10 +405,6 @@ class Controller extends ModuleAbstract implements WebInterface $account->setName3($request->getData('name3')); $account->setEmail($request->getData('email')); $account->generatePassword($request->getData('password')); - - AccountMapper::create($account); - - $response->set('account', $account->jsonSerialize()); } public function apiAccountDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) From 7c4a4c91d2fd169f0b6792f90ec6dab71151713f Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 9 Jul 2017 10:42:02 +0200 Subject: [PATCH 2/2] (Draft) Create risk management models Also fix some belongsTo in other mappers. --- Models/AccountMapper.php | 2 +- Models/GroupMapper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Models/AccountMapper.php b/Models/AccountMapper.php index 2590791..63855ed 100644 --- a/Models/AccountMapper.php +++ b/Models/AccountMapper.php @@ -192,6 +192,6 @@ class AccountMapper extends DataMapperAbstract */ public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null) { - return parent::get((int) $primaryKey, $relations, $fill); + return parent::get($primaryKey, $relations, $fill); } } diff --git a/Models/GroupMapper.php b/Models/GroupMapper.php index 61e73b7..a0b716b 100644 --- a/Models/GroupMapper.php +++ b/Models/GroupMapper.php @@ -74,6 +74,6 @@ class GroupMapper extends DataMapperAbstract */ public static function get($primaryKey, int $relations = RelationType::ALL, $fill = null) { - return parent::get((int) $primaryKey, $relations, $fill); + return parent::get($primaryKey, $relations, $fill); } }