// Note
// Custom
- // Cache the various object fields
- static $fields = [];
-
// first add core contact values since for other Civi modules they are not added
$contactFields = CRM_Contact_DAO_Contact::fields();
_civicrm_api3_store_values($contactFields, $values, $params);
return TRUE;
}
+ // Cache the various object fields
+ // @todo - remove this after confirming this is just a compilation of other-wise-cached fields.
+ static $fields = [];
+
if (isset($values['individual_prefix'])) {
if (!empty($params['prefix_id'])) {
$prefixes = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id');
}
// Check for custom field values
-
- if (empty($fields['custom'])) {
- $fields['custom'] = &CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
- FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
- );
- }
+ $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $values),
+ FALSE, FALSE, NULL, NULL, FALSE, FALSE, FALSE
+ );
foreach ($values as $key => $value) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
// check if it's a valid custom field id
- if (!array_key_exists($customFieldID, $fields['custom'])) {
+ if (!array_key_exists($customFieldID, $customFields)) {
return civicrm_api3_create_error('Invalid custom field ID');
}
else {
*
* @return bool
* the result of this processing
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) {
$config = CRM_Core_Config::singleton();
'contact_type' => $this->_contactType,
];
- static $contactFields = NULL;
- if ($contactFields == NULL) {
- $contactFields = CRM_Contact_DAO_Contact::import();
- }
+ $contactFields = CRM_Contact_DAO_Contact::import();
//check if external identifier exists in database
if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, [
*/
public function testImportFill() {
// Create a custom field group for testing.
- $custom_group_name = 'importFillGroup';
- $results = $this->callAPISuccess('customGroup', 'get', ['title' => $custom_group_name]);
- if ($results['count'] == 0) {
- $api_params = [
- 'title' => $custom_group_name,
- 'extends' => 'Individual',
- 'is_active' => TRUE,
- ];
- $customGroup = $this->callAPISuccess('customGroup', 'create', $api_params);
- }
+ $this->createCustomGroup([
+ 'title' => 'importFillGroup',
+ 'extends' => 'Individual',
+ 'is_active' => TRUE,
+ ]);
+ $customGroupID = $this->ids['CustomGroup']['importFillGroup'];
// Add two custom fields.
$api_params = [
- 'custom_group_id' => $customGroup['id'],
+ 'custom_group_id' => $customGroupID,
'label' => 'importFillField1',
'html_type' => 'Select',
'data_type' => 'String',
$customField1 = $result['id'];
$api_params = [
- 'custom_group_id' => $customGroup['id'],
+ 'custom_group_id' => $customGroupID,
'label' => 'importFillField2',
'html_type' => 'Select',
'data_type' => 'String',
// Now set up values.
$original_gender = 'Male';
$original_custom1 = 'foo';
- $original_job_title = '';
- $original_custom2 = '';
$original_email = 'test-import-fill@example.org';
$import_gender = 'Female';