Commit 0d0c3798 authored by jaapjansma's avatar jaapjansma

improvements to the abstract api class

parent 268c04c2
......@@ -375,13 +375,7 @@ abstract class AbstractApi implements API_ProviderInterface, EventSubscriberInte
$records = $dataProcessorClass->getDataFlow()->allRecords();
$values = array();
foreach($records as $idx => $record) {
foreach($record as $fieldname => $field) {
if ($field instanceof arrayFieldOutput) {
$values[$idx][$fieldname] = $field->getArrayData();
} else {
$values[$idx][$fieldname] = $field->formattedValue;
}
}
$values[$idx] = $this->getRecordData($record, $dataProcessorClass);
}
$return = array(
'values' => $values,
......@@ -399,6 +393,26 @@ abstract class AbstractApi implements API_ProviderInterface, EventSubscriberInte
}
}
/**
* Process a record from the data processor the api data.
*
* @param $record
* @param \Civi\DataProcessor\ProcessorType\AbstractProcessorType $dataProcessorClass
*
* @return array
*/
protected function getRecordData($record, AbstractProcessorType $dataProcessorClass) {
$data = array();
foreach($record as $fieldname => $field) {
if ($field instanceof arrayFieldOutput) {
$data[$fieldname] = $field->getArrayData();
} else {
$data[$fieldname] = $field->formattedValue;
}
}
return $data;
}
/**
* Check for errors in the CiviCRM Status messages list
* and if errors are present create a civicrm api return error with the messages in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment