From 39578dc27e70142ceb9d31e7eb5388d740012557 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 16 Dec 2018 11:25:35 +0100 Subject: [PATCH] Implement tests --- Controller/ApiController.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 77c7cd0..e34b615 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -49,35 +49,27 @@ final class ApiController extends Controller $created = []; foreach ($profiles as $profile) { - $this->apiProfileCreateDbEntry($profile); + $this->apiProfileCreateDbEntry($profile, $request); - $created[] = $profile->jsonSerialize(); + $created[] = $profile; } - $response->set($request->getUri()->__toString(), [ - 'status' => NotificationLevel::OK, - 'title' => 'Profile(s)', - 'message' => 'Profile(s) successfully created.', - 'response' => $created - ]); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Profil', 'Profil successfully created.', $created); } /** - * @param Profile $profile Profile to create in the database + * @param Profile $profile Profile to create in the database + * @param RequestAbstract $request Request * * @return void * * @since 1.0.0 */ - public function apiProfileCreateDbEntry(Profile $profile) : void + public function apiProfileCreateDbEntry(Profile $profile, RequestAbstract $request) : void { - $this->app->eventManager->trigger('PRE:Module:Admin-profile-create', '', $profile); - ProfileMapper::create($profile); - $this->app->eventManager->trigger('POST:Module:Admin-profile-create', '', [ - $profile->getAccount()->getId(), - null, - $profile, - ]); + if ($profile->getId() === 0) { + $this->createModel($request, $profile, ProfileMapper::class, 'profile'); + } } /**