Skip to content
Snippets Groups Projects
Commit c358abca authored by eileen's avatar eileen
Browse files

Remove entity_field_prefix

parent 8ded49c0
Branches
No related tags found
No related merge requests found
......@@ -111,7 +111,6 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Import_Parser {
'text' => ts('Activity Fields'),
'entity_title' => ts('Activity'),
'is_contact' => FALSE,
'entity_field_prefix' => 'Activity.',
'actions' => [
['id' => 'save', 'text' => ts('Create or Update using ID'), 'description' => ts('Skip if no match found')],
],
......@@ -125,7 +124,6 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Import_Parser {
'text' => ts('Target Contact Fields'),
'entity_title' => ts('Target Contact'),
'is_contact' => TRUE,
'entity_field_prefix' => 'target_contact.',
'unique_fields' => ['external_identifier', 'id'],
'supports_multiple' => TRUE,
'actions' => $this->getActions(['select', 'ignore', 'update']),
......@@ -140,7 +138,6 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Import_Parser {
'text' => ts('Source Contact Fields'),
'entity_title' => ts('Source Contact'),
'is_contact' => TRUE,
'entity_field_prefix' => 'source_contact.',
'unique_fields' => ['external_identifier', 'id'],
'supports_multiple' => FALSE,
'actions' => $this->isUpdateExisting() ? $this->getActions(['ignore']) : $this->getActions(['select', 'update', 'save']),
......@@ -154,7 +151,6 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Import_Parser {
'text' => ts('assignee Contact Fields'),
'entity_title' => ts('Assignee Contact'),
'is_contact' => TRUE,
'entity_field_prefix' => 'AssigneeContact.',
'unique_fields' => ['external_identifier', 'id'],
'supports_multiple' => TRUE,
'actions' => $this->getActions(['select', 'ignore']),
......
......@@ -331,7 +331,6 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser {
'default_action' => $this->isUpdateExisting() ? 'update' : 'create',
'entity_name' => 'Contribution',
'entity_title' => ts('Contribution'),
'entity_field_prefix' => 'Contribution.',
'selected' => ['action' => $this->isUpdateExisting() ? 'update' : 'create'],
],
'Contact' => [
......@@ -345,7 +344,6 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser {
'contact_type' => $this->getSubmittedValue('contactType'),
'dedupe_rule' => $this->getDedupeRule($this->getContactType())['name'],
],
'entity_field_prefix' => 'Contact.',
'default_action' => 'select',
'entity_name' => 'Contact',
'entity_title' => ts('Contribution Contact'),
......@@ -366,7 +364,6 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Import_Parser {
],
'default_action' => 'ignore',
'entity_name' => 'SoftCreditContact',
'entity_field_prefix' => 'SoftCreditContact.',
'entity_title' => ts('Soft Credit Contact'),
'entity_data' => [
'soft_credit_type_id' => [
......
......@@ -74,13 +74,11 @@ class CRM_Event_Import_Parser_Participant extends CRM_Import_Parser {
'default_action' => $this->isUpdateExisting() ? 'update' : 'create',
'entity_name' => 'Participant',
'entity_title' => ts('Participant'),
'entity_field_prefix' => 'Participant.',
'selected' => ['action' => $this->isUpdateExisting() ? 'update' : 'create'],
],
'Contact' => [
'text' => ts('Contact Fields'),
'is_contact' => TRUE,
'entity_field_prefix' => 'Contact.',
'unique_fields' => ['external_identifier', 'id'],
'supports_multiple' => FALSE,
'actions' => $this->isUpdateExisting() ? $this->getActions(['ignore', 'update']) : $this->getActions(['select', 'update', 'save']),
......
......@@ -1014,19 +1014,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
$fieldMap = $this->getOddlyMappedMetadataFields();
$fieldMapName = empty($fieldMap[$fieldName]) ? $fieldName : $fieldMap[$fieldName];
foreach ($this->getImportEntities() as $entity) {
if (empty($this->getImportableFieldsMetadata()[$fieldMapName]) && $entity['entity_field_prefix'] && str_starts_with($fieldMapName, $entity['entity_field_prefix'])) {
// e.g if the field name is 'contact.external_identifier' then it is just a case of looking
// for external_identifier.
$fieldMapName = substr($fieldMapName, strlen($entity['entity_field_prefix']));
break;
}
}
if (isset($this->baseEntity) && str_starts_with($fieldMapName, strtolower($this->baseEntity) . '.')) {
// @todo - remove this again - we are switching to NOT namespacing the base entity & using the getImportEntities above.
$fieldMapName = str_replace(strtolower($this->baseEntity) . '.', '', $fieldMapName);
}
// This whole business of only loading metadata for one type when we actually need it for all is ... dubious.
// This whole business of only loading metadata for one contact type when we actually need it for all is ... dubious.
if (empty($this->getImportableFieldsMetadata()[$fieldMapName])) {
if ($loadOptions || !$limitToContactType) {
$this->importableFieldsMetadata[$fieldMapName] = CRM_Contact_BAO_Contact::importableFields('All')[$fieldMapName];
......@@ -1159,13 +1147,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
protected function validateParams(array $params): void {
if (empty($params['id']) && empty($params[$this->baseEntity]['id'])) {
$entityConfiguration = $this->getImportEntities()[$this->baseEntity];
$entity = '';
if (!empty($entityConfiguration['entity_field_prefix'])) {
// entity_field_prefix is our current way of showing if a table is prefixed
// it might change to only using entity_name based on thinking in
// https://github.com/civicrm/civicrm-core/pull/32317
$entity = $entityConfiguration['entity_name'];
}
$entity = $entityConfiguration['entity_name'] ?? '';
$this->validateRequiredFields($this->getRequiredFields(), $params[$this->baseEntity] ?? $params, $entity);
}
$errors = [];
......@@ -1326,7 +1308,7 @@ abstract class CRM_Import_Parser implements UserJobInterface {
*/
public function getImportEntities() : array {
return [
'Contact' => ['text' => ts('Contact Fields'), 'is_contact' => TRUE, 'entity_field_prefix' => ''],
'Contact' => ['text' => ts('Contact Fields'), 'is_contact' => TRUE],
];
}
......
......@@ -75,13 +75,11 @@ class CRM_Member_Import_Parser_Membership extends CRM_Import_Parser {
'default_action' => $this->isUpdateExisting() ? 'update' : 'create',
'entity_name' => 'Membership',
'entity_title' => ts('Membership'),
'entity_field_prefix' => 'Membership.',
'selected' => ['action' => $this->isUpdateExisting() ? 'update' : 'create'],
],
'Contact' => [
'text' => ts('Contact Fields'),
'is_contact' => TRUE,
'entity_field_prefix' => 'contact.',
'unique_fields' => ['external_identifier', 'id'],
'supports_multiple' => FALSE,
'actions' => $this->isUpdateExisting() ? $this->getActions(['ignore', 'update']) : $this->getActions(['select', 'update', 'save']),
......
......@@ -111,7 +111,7 @@
var selected = $scope.data.entities[entity.entity_name].selected;
if (selected.action !== 'ignore') {
availableEntity = _.clone(entity);
availableEntity.children = filterEntityFields(entity.is_contact, entity.children, selected, entity.entity_field_prefix);
availableEntity.children = filterEntityFields(entity.is_contact, entity.children, selected, entity.entity_name + '.');
fields.push(availableEntity);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment