public function MigrationDataImport::prepareDefaultValues in CRM Core 7
Prepare row for setting default values.
1 call to MigrationDataImport::prepareDefaultValues()
- MigrationDataImport::prepareRow in modules/
crm_core_data_import/ includes/ controllers/ MigrationDataImport.inc - This method is called from the source plugin upon first pulling the raw data from the source.
File
- modules/
crm_core_data_import/ includes/ controllers/ MigrationDataImport.inc, line 291 - Handler for migration process.
Class
- MigrationDataImport
- @file Handler for migration process.
Code
public function prepareDefaultValues(&$row) {
// Remove values from row, if they are empty and have default value.
$importer = $this
->getImporter();
$entity_type = $this
->getEntityType();
$entity_bundle = $this
->getEntityBundle();
$delta = $this
->getDelta();
$mapping = $importer
->getMappingSettings();
$destination = $importer
->getDestinationsForEntity($this
->getEntityType(), $this
->getEntityBundle(), $this
->getDelta());
if ($destination->entityType == $entity_type && $destination->bundle == $entity_bundle && !empty($mapping[$destination->controller . ':' . $destination->bundle . ':' . $delta])) {
$fields_mapping = $mapping[$destination->controller . ':' . $destination->bundle . ':' . $delta];
foreach ($fields_mapping as $field) {
if (!empty($field['default_value']) && !empty($field['source_field']) && empty($row->{$field['source_field']})) {
unset($row->{$field['source_field']});
}
}
}
}