diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 7da3862..1bed8f6 100644 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -49,9 +49,7 @@ final class ApiController extends Controller $created = []; foreach ($profiles as $profile) { - $this->app->eventManager->trigger('PRE:Module:Admin-profile-create', '', $profile); - ProfileMapper::create($profile); - $this->app->eventManager->trigger('POST:Module:Admin-profile-create', '', $profile); + $this->apiProfileCreateDbEntry($profile); $created[] = $profile->jsonSerialize(); } @@ -64,6 +62,24 @@ final class ApiController extends Controller ]); } + /** + * @param Profile $profile Profile to create in the database + * + * @return void + * + * @since 1.0.0 + */ + public function apiProfileCreateDbEntry(Profile $profile) : 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, + ]); + } + /** * Method to create profile from request. * diff --git a/Models/Profile.php b/Models/Profile.php index d10ba1f..cf61679 100644 --- a/Models/Profile.php +++ b/Models/Profile.php @@ -29,7 +29,7 @@ use phpOMS\Stdlib\Base\Location; * @link http://website.orange-management.de * @since 1.0.0 */ -class Profile +class Profile implements \JsonSerializable { /** * Id.