From 6e6b100f1e1b5bd7f709ce3e7be71c2e48afbeec Mon Sep 17 00:00:00 2001 From: Damien <damien.burel@maarch.org> Date: Wed, 7 Mar 2018 15:09:19 +0100 Subject: [PATCH] FEAT #163 ListTemplate getById Data --- src/app/entity/controllers/ListTemplateController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/entity/controllers/ListTemplateController.php b/src/app/entity/controllers/ListTemplateController.php index 0af7de2271e..d335c351b25 100644 --- a/src/app/entity/controllers/ListTemplateController.php +++ b/src/app/entity/controllers/ListTemplateController.php @@ -49,6 +49,15 @@ class ListTemplateController if (empty($listTemplates)) { return $response->withStatus(400)->withJson(['errors' => 'List template not found']); } + foreach ($listTemplates as $key => $value) { + if ($value['item_type'] == 'entity_id') { + $listTemplates[$key]['idToDisplay'] = EntityModel::getById(['entityId' => $value['item_id'], 'select' => ['entity_label']])['entity_label']; + $listTemplates[$key]['descriptionToDisplay'] = ''; + } else { + $listTemplates[$key]['idToDisplay'] = UserModel::getLabelledUserById(['userId' => $value['item_id']]); + $listTemplates[$key]['descriptionToDisplay'] = UserModel::getPrimaryEntityByUserId(['userId' => $value['item_id']])['entity_label']; + } + } $listTemplate = [ 'object_id' => $listTemplates[0]['object_id'], 'object_type' => $listTemplates[0]['object_type'], -- GitLab