Profile.php
This api exposes CiviCRM profiles.
Profiles are collections of fields used as forms, listings, search columns, etc.
Table of Contents
Functions
- civicrm_api3_profile_get() : array<string|int, mixed>
- Retrieve Profile field values.
- _civicrm_api3_profile_get_spec() : mixed
- Adjust profile get function metadata.
- civicrm_api3_profile_submit() : array<string|int, mixed>
- Submit a set of fields against a profile.
- _civicrm_api3_profile_translate_fieldnames_for_bao() : string
- Translate field names for BAO.
- _civicrm_api3_profile_submit_spec() : mixed
- Metadata for submit action.
- civicrm_api3_profile_set() : array<string|int, mixed>
- Update Profile field values.
- civicrm_api3_profile_apply() : array<string|int, mixed>
- Apply profile.
- _civicrm_api3_profile_apply_spec() : mixed
- Adjust Metadata for Apply action.
- _civicrm_api3_profile_getbillingpseudoprofile() : array<string|int, mixed>
- Get pseudo profile 'billing'.
- _civicrm_api3_buildprofile_submitfields() : array<string|int, mixed>|void
- Here we will build up getfields type data for all the fields in the profile.
- _civicrm_api3_order_by_weight() : bool
- _civicrm_api3_map_profile_fields_to_entity() : array<string|int, mixed>
- Here we map the profile fields as stored in the uf_field table to their 'real entity' we also return the profile fieldname
- _civicrm_api3_profile_getProfileID() : int|string
- _civicrm_api3_profile_appendaliases() : array<string|int, mixed>
- helper function to add all aliases as keys to getfields response so we can look for keys within it since the relationship between profile fields & api / metadata based fields is a bit inconsistent
- _civicrm_api3_profile_deprecation() : array<string|int, mixed>
Functions
civicrm_api3_profile_get()
Retrieve Profile field values.
civicrm_api3_profile_get(array<string|int, mixed> $params) : array<string|int, mixed>
NOTE this api is not standard & since it is tested we need to honour that but the correct behaviour is for it to return an id indexed array as this supports multiple instances - if a single profile is passed in we will not return a normal api result array in order to avoid breaking code. (This could still be confusing :-( but we have to keep the tested behaviour working
Note that if contact_id is empty an array of defaults is returned
Parameters
- $params : array<string|int, mixed>
-
Associative array of property name/value. pairs to get profile field values
Tags
Return values
array<string|int, mixed>_civicrm_api3_profile_get_spec()
Adjust profile get function metadata.
_civicrm_api3_profile_get_spec(array<string|int, mixed> &$params) : mixed
Parameters
- $params : array<string|int, mixed>
civicrm_api3_profile_submit()
Submit a set of fields against a profile.
civicrm_api3_profile_submit(array<string|int, mixed> $params) : array<string|int, mixed>
Note choice of submit versus create is discussed CRM-13234 & related to the fact 'profile' is being treated as a data-entry entity
Parameters
- $params : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —API result array
_civicrm_api3_profile_translate_fieldnames_for_bao()
Translate field names for BAO.
_civicrm_api3_profile_translate_fieldnames_for_bao(string $fieldName) : string
The api standards expect field names to be lower case but the BAO uses mixed case so we accept 'email-primary' but pass 'email-Primary' to the BAO we could make the BAO handle email-primary but this would alter the fieldname seen by hooks & we would need to consider that change
Parameters
- $fieldName : string
-
API field name.
Return values
string —BAO Field Name
_civicrm_api3_profile_submit_spec()
Metadata for submit action.
_civicrm_api3_profile_submit_spec(array<string|int, mixed> &$params, array<string|int, mixed> $apirequest) : mixed
Parameters
- $params : array<string|int, mixed>
- $apirequest : array<string|int, mixed>
civicrm_api3_profile_set()
Update Profile field values.
- calling this function directly is deprecated as 'set' is not a clear action use submit
civicrm_api3_profile_set(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Array of property name/value. pairs to update profile field values
Return values
array<string|int, mixed> —Updated Contact/ Activity object|CRM_Error
civicrm_api3_profile_apply()
Apply profile.
- appears to be an internal function - should not be accessible via api Provide formatted values for profile fields.
civicrm_api3_profile_apply(array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed>
-
Array of property name/value. pairs to profile field values
Tags
Return values
array<string|int, mixed>_civicrm_api3_profile_apply_spec()
Adjust Metadata for Apply action.
_civicrm_api3_profile_apply_spec(array<string|int, mixed> &$params) : mixed
The metadata is used for setting defaults, documentation & validation.
Parameters
- $params : array<string|int, mixed>
-
Array of parameters determined by getfields.
_civicrm_api3_profile_getbillingpseudoprofile()
Get pseudo profile 'billing'.
_civicrm_api3_profile_getbillingpseudoprofile(array<string|int, mixed> &$params) : array<string|int, mixed>
This is a function to help us 'pretend' billing is a profile & treat it like it is one. It gets standard credit card address fields etc Note this is 'better' that the inbuilt version as it will pull in fallback values billing location -> is_billing -> primary
Note that that since the existing code for deriving a blank profile is not easily accessible our interim solution is just to return an empty array
Parameters
- $params : array<string|int, mixed>
Return values
array<string|int, mixed>_civicrm_api3_buildprofile_submitfields()
Here we will build up getfields type data for all the fields in the profile.
_civicrm_api3_buildprofile_submitfields(int $profileID, int $optionsBehaviour, bool $is_flush) : array<string|int, mixed>|void
Because the integration with the form layer in core is so hard-coded we are not going to attempt to re-use it However, as this function is unit-tested & hence 'locked in' we can aspire to extract sharable code out of the form-layer over time.
The function deciphers which fields belongs to which entites & retrieves metadata about the entities Unfortunately we have inconsistencies such as 'contribution' uses contribution_status_id & participant has 'participant_status' so we have to standardise from the outside in here - find the oddities, 'mask them' at this layer, add tests & work to standardise over time so we can remove this handling
Parameters
- $profileID : int
- $optionsBehaviour : int
-
0 = don't resolve, 1 = resolve non-aggressively, 2 = resolve aggressively - ie include country & state.
- $is_flush : bool
Return values
array<string|int, mixed>|void_civicrm_api3_order_by_weight()
_civicrm_api3_order_by_weight(array<string|int, mixed> $a, array<string|int, mixed> $b) : bool
Parameters
- $a : array<string|int, mixed>
- $b : array<string|int, mixed>
Return values
bool_civicrm_api3_map_profile_fields_to_entity()
Here we map the profile fields as stored in the uf_field table to their 'real entity' we also return the profile fieldname
_civicrm_api3_map_profile_fields_to_entity(array<string|int, mixed> &$field) : array<string|int, mixed>
Parameters
- $field : array<string|int, mixed>
Return values
array<string|int, mixed>_civicrm_api3_profile_getProfileID()
_civicrm_api3_profile_getProfileID(int $profileID) : int|string
Parameters
- $profileID : int
Tags
Return values
int|string_civicrm_api3_profile_appendaliases()
helper function to add all aliases as keys to getfields response so we can look for keys within it since the relationship between profile fields & api / metadata based fields is a bit inconsistent
_civicrm_api3_profile_appendaliases(array<string|int, mixed> $values, string $entity) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
-
e.g getfields response incl 'membership_type_id' - with api.aliases = 'membership_type' returned array will include both as keys (with the same values)
- $entity : string
Return values
array<string|int, mixed>_civicrm_api3_profile_deprecation()
api notice
_civicrm_api3_profile_deprecation() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array of deprecated actions