Skip to content

Commit

Permalink
Improve query that returns EIS lookup table for Person canvas JavaScr…
Browse files Browse the repository at this point in the history
…ipt components (CFM-417)
  • Loading branch information
arlen committed Feb 17, 2026
1 parent bc5b9ca commit d4d04e4
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions app/src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit d4d04e4

Please sign in to comment.