+ // Expand the superstar 'custom.*' to select all fields in all custom groups
+ $customStar = array_search('custom.*', array_values($select), TRUE);
+ if ($customStar !== FALSE) {
+ $customGroups = civicrm_api4($this->getEntity(), 'getFields', [
+ 'checkPermissions' => FALSE,
+ 'where' => [['custom_group', 'IS NOT NULL']],
+ ], ['custom_group' => 'custom_group']);
+ $customSelect = [];
+ foreach ($customGroups as $groupName) {
+ $customSelect[] = "$groupName.*";
+ }
+ array_splice($select, $customStar, 1, $customSelect);
+ }
+