-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15028 from eileenmcnaughton/import_processor
[Test] [Ref] [Import]Add wrapper class for importProcessor
- 5.82.0
- 5.81.2
- 5.81.1
- 5.81.0
- 5.80.3
- 5.80.2
- 5.80.1
- 5.80.0
- 5.79.2
- 5.79.1
- 5.79.0
- 5.78.4
- 5.78.3
- 5.78.2
- 5.78.1
- 5.78.0
- 5.77.1
- 5.77.0
- 5.76.3
- 5.76.2
- 5.76.1
- 5.76.0
- 5.75.2
- 5.75.1
- 5.75.0
- 5.74.5
- 5.74.4
- 5.74.3
- 5.74.2
- 5.74.1
- 5.74.0
- 5.73.4
- 5.73.3
- 5.73.2
- 5.73.1
- 5.73.0
- 5.72.3
- 5.72.2
- 5.72.1
- 5.72.0
- 5.71.2
- 5.71.1
- 5.71.0
- 5.70.2
- 5.70.1
- 5.70.0
- 5.69.5
- 5.69.4
- 5.69.3
- 5.69.2
- 5.69.1
- 5.69.0
- 5.68.1
- 5.68.0
- 5.67.3
- 5.67.2
- 5.67.1
- 5.67.0
- 5.66.2
- 5.66.1
- 5.66.0
- 5.65.2
- 5.65.1
- 5.65.0
- 5.64.4
- 5.64.3
- 5.64.2
- 5.64.1
- 5.64.0
- 5.63.3
- 5.63.2
- 5.63.1
- 5.63.0
- 5.62.1
- 5.62.0
- 5.61.4
- 5.61.3
- 5.61.2
- 5.61.1
- 5.61.0
- 5.60.0
- 5.59.4
- 5.59.3
- 5.59.2
- 5.59.1
- 5.59.0
- 5.58.1
- 5.58.0
- 5.57.3
- 5.57.2
- 5.57.1
- 5.57.0
- 5.56.2
- 5.56.1
- 5.56.0
- 5.55.2
- 5.55.1
- 5.55.0
- 5.54.2
- 5.54.1
- 5.54.0
- 5.53.0
- 5.52.3
- 5.52.2
- 5.52.1
- 5.52.0
- 5.51.3
- 5.51.2
- 5.51.1
- 5.51.0
- 5.50.4
- 5.50.3
- 5.50.2
- 5.50.1
- 5.50.0
- 5.49.5
- 5.49.4
- 5.49.3
- 5.49.2
- 5.49.1
- 5.49.0
- 5.48.2
- 5.48.1
- 5.48.0
- 5.47.4
- 5.47.3
- 5.47.2
- 5.47.1
- 5.47.0
- 5.46.3
- 5.46.2
- 5.46.1
- 5.46.0
- 5.45.3
- 5.45.2
- 5.45.1
- 5.45.0
- 5.44.0
- 5.43.2
- 5.43.1
- 5.43.0
- 5.42.1
- 5.42.0
- 5.41.2
- 5.41.1
- 5.41.0
- 5.40.4
- 5.40.3
- 5.40.2
- 5.40.1
- 5.40.0
- 5.39.1
- 5.39.0
- 5.38.1
- 5.38.0
- 5.37.2
- 5.37.1
- 5.37.0
- 5.36.1
- 5.36.0
- 5.35.2
- 5.35.1
- 5.35.0
- 5.34.0
- 5.33.2
- 5.33.1
- 5.33.0
- 5.32.2
- 5.32.1
- 5.32.0
- 5.31.1
- 5.31.0
- 5.30.1
- 5.30.0
- 5.29.1
- 5.29.0
- 5.28.4
- 5.28.3
- 5.28.2
- 5.28.1
- 5.28.0
- 5.27.4
- 5.27.3
- 5.27.2
- 5.27.1
- 5.27.0
- 5.26.2
- 5.26.1
- 5.26.0
- 5.25.0
- 5.24.6
- 5.24.5
- 5.24.4
- 5.24.3
- 5.24.2
- 5.24.1
- 5.24.0
- 5.23.4
- 5.23.3
- 5.23.2
- 5.23.1
- 5.23.0
- 5.22.1
- 5.22.0
- 5.21.2
- 5.21.1
- 5.21.0
- 5.20.3
- 5.20.2
- 5.20.1
- 5.20.0
- 5.19.4
- 5.19.3
- 5.19.2
- 5.19.1
- 5.19.0
- 5.18.4
- 5.18.3
- 5.18.2
- 5.18.1
- 5.18.0
Showing
3 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?php | ||
|
||
/** | ||
* Class CRM_Import_ImportProcessor. | ||
* | ||
* Import processor class. This is intended to provide a sanitising wrapper around | ||
* the form-oriented import classes. In particular it is intended to provide a clear translation | ||
* between the saved mapping field format and the quick form & parser formats. | ||
* | ||
* In the first instance this is only being used in unit tests but the intent is to migrate | ||
* to it on a trajectory similar to the ExportProcessor so it is not in the tests. | ||
*/ | ||
class CRM_Import_ImportProcessor { | ||
|
||
/** | ||
* An array of fields in the format used in the table civicrm_mapping_field. | ||
* | ||
* @var array | ||
*/ | ||
protected $mappingFields = []; | ||
|
||
/** | ||
* Get contact type being imported. | ||
* | ||
* @var string | ||
*/ | ||
protected $contactType; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getContactType(): string { | ||
return $this->contactType; | ||
} | ||
|
||
/** | ||
* @param string $contactType | ||
*/ | ||
public function setContactType(string $contactType) { | ||
$this->contactType = $contactType; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getMappingFields(): array { | ||
return $this->mappingFields; | ||
} | ||
|
||
/** | ||
* @param array $mappingFields | ||
*/ | ||
public function setMappingFields(array $mappingFields) { | ||
$this->mappingFields = CRM_Utils_Array::rekey($mappingFields, 'column_number'); | ||
ksort($this->mappingFields); | ||
$this->mappingFields = array_values($this->mappingFields); | ||
} | ||
|
||
/** | ||
* Get the names of the mapped fields. | ||
*/ | ||
public function getFieldNames() { | ||
return CRM_Utils_Array::collect('name', $this->getMappingFields()); | ||
} | ||
|
||
/** | ||
* Get the location types of the mapped fields. | ||
*/ | ||
public function getFieldLocationTypes() { | ||
return CRM_Utils_Array::collect('location_type_id', $this->getMappingFields()); | ||
} | ||
|
||
/** | ||
* Get the phone types of the mapped fields. | ||
*/ | ||
public function getFieldPhoneTypes() { | ||
return CRM_Utils_Array::collect('phone_type_id', $this->getMappingFields()); | ||
} | ||
|
||
/** | ||
* Get the names of the im_provider fields. | ||
*/ | ||
public function getFieldIMProviderTypes() { | ||
return CRM_Utils_Array::collect('im_provider_id', $this->getMappingFields()); | ||
} | ||
|
||
/** | ||
* Get the names of the website fields. | ||
*/ | ||
public function getFieldWebsiteTypes() { | ||
return CRM_Utils_Array::collect('im_provider_id', $this->getMappingFields()); | ||
} | ||
|
||
/** | ||
* Get an instance of the importer object. | ||
* | ||
* @return CRM_Contact_Import_Parser_Contact | ||
*/ | ||
public function getImporterObject() { | ||
$importer = new CRM_Contact_Import_Parser_Contact( | ||
$this->getFieldNames(), | ||
$this->getFieldLocationTypes(), | ||
$this->getFieldPhoneTypes(), | ||
$this->getFieldIMProviderTypes(), | ||
// @todo - figure out related mappings. | ||
// $mapperRelated = [], $mapperRelatedContactType = [], $mapperRelatedContactDetails = [], $mapperRelatedContactLocType = [], $mapperRelatedContactPhoneType = [], $mapperRelatedContactImProvider = [], | ||
[], | ||
[], | ||
[], | ||
[], | ||
[], | ||
[], | ||
$this->getFieldWebsiteTypes() | ||
// $mapperRelatedContactWebsiteType = [] | ||
); | ||
$importer->init(); | ||
$importer->_contactType = $this->getContactType(); | ||
return $importer; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters