From d4d04e43cf4f5e74f2ce847828ee155eb4a2771d Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Tue, 17 Feb 2026 14:04:45 -0500 Subject: [PATCH] Improve query that returns EIS lookup table for Person canvas JavaScript components (CFM-417) --- app/src/Controller/PeopleController.php | 37 +++++++++++++------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/app/src/Controller/PeopleController.php b/app/src/Controller/PeopleController.php index 5b234fbf9..c37e1ca81 100644 --- a/app/src/Controller/PeopleController.php +++ b/app/src/Controller/PeopleController.php @@ -91,28 +91,29 @@ public function beforeRender(\Cake\Event\EventInterface $event) { } if(!$this->request->is('restful') && $this->request->getParam('action') == 'edit') { - // Get the external identity sources for this person - $externalIdentitySources = $this->fetchTable('ExternalIdentities') - ->find() - ->where(['ExternalIdentities.person_id' => $this->request->getParam('pass.0')]) - ->contain([ - 'ExtIdentitySourceRecords' => [ - 'ExternalIdentitySources' - ] + // Create a lookup table for badging External Identity Source descriptions on Person Canvas MVEAS. + // This will be passed to the view and made available to the JavaScript components. + $extIdentities = TableRegistry::getTableLocator()->get('ExternalIdentities'); + $personId = $this->request->getParam('pass.0'); + $eisLookupTable = $extIdentities + ->find('list', [ + 'keyField' => 'id', + 'valueField' => 'description', ]) - ->all(); - - // Create a lookup table for badging EIS descriptions on Person Canvas MVEAS - $eisLookupTable = []; - foreach ($externalIdentitySources as $extIdentity) { - if (!empty($extIdentity->ext_identity_source_record) && - !empty($extIdentity->ext_identity_source_record->external_identity_source)) { - $eisLookupTable[$extIdentity->id] = $extIdentity->ext_identity_source_record->external_identity_source->description; - } - } + ->select([ + 'id' => 'ExternalIdentities.id', + 'description' => 'ExternalIdentitySources.description', + ]) + ->innerJoinWith('ExtIdentitySourceRecords.ExternalIdentitySources') + ->where([ + 'ExternalIdentities.person_id' => $personId, + ]) + ->enableHydration(false) + ->toArray(); $this->set('vv_external_identity_sources', $eisLookupTable); } + return parent::beforeRender($event); } } \ No newline at end of file