From 003053f13db5b78c9ef11249c5136d8d0d87de80 Mon Sep 17 00:00:00 2001 From: iglocska Date: Fri, 4 Nov 2022 09:58:55 +0100 Subject: [PATCH] new: [API rearrange] added a simplifier for commonly used objects - let's only return the subset of the data required to identify and retrieve the related data --- src/Model/Entity/AppModel.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Model/Entity/AppModel.php b/src/Model/Entity/AppModel.php index 5b639b4..8dcd07f 100644 --- a/src/Model/Entity/AppModel.php +++ b/src/Model/Entity/AppModel.php @@ -99,4 +99,22 @@ class AppModel extends Entity } return $rearrangedAlignments; } + + public function rearrangeSimplify(array $typesToRearrange): void + { + if (in_array('organisation', $typesToRearrange) && isset($this->organisation)) { + $this->organisation = [ + 'id' => $this->organisation['id'], + 'name' => $this->organisation['name'], + 'uuid' => $this->organisation['uuid'] + ]; + } + if (in_array('individual', $typesToRearrange) && isset($this->individual)) { + $this->individual = [ + 'id' => $this->individual['id'], + 'email' => $this->individual['email'], + 'uuid' => $this->individual['uuid'] + ]; + } + } }