Skip to content

Commit

Permalink
Start extracting the transform funcition
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Feb 1, 2021
1 parent b601408 commit a4b1d26
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions CRM/Activity/Import/Parser/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,7 @@ public function import($onDuplicate, &$values) {
catch (CRM_Core_Exception $e) {
return $this->addError($values, [$e->getMessage()]);
}

$params = $this->getActiveFieldParams();
$activityLabel = array_search('activity_label', $this->_mapperKeys);
if ($activityLabel) {
$params = array_merge($params, ['activity_label' => $values[$activityLabel]]);
}
$params = $this->getApiReadyParams($values);
// For date-Formats.
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
Expand Down Expand Up @@ -421,4 +416,24 @@ protected function validateValues(array $values): void {
$this->validateCustomFields($values);
}

/**
* Get array of parameters formatted for the api from the submitted values.
*
* @param array $values
*
* @return array
*/
protected function getApiReadyParams(array $values): array {
$this->setActiveFieldValues($values);
$params = $this->getActiveFieldParams();
if ($this->getFieldValue($values, 'activity_label')) {
$params['activity_type_id'] = array_search(
$this->getFieldValue($values, 'activity_label'),
CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create'),
TRUE
);
}
return $params;
}

}

0 comments on commit a4b1d26

Please sign in to comment.