Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ayduns
dataprocessor
Commits
0d0c3798
Commit
0d0c3798
authored
May 04, 2020
by
jaapjansma
Browse files
improvements to the abstract api class
parent
268c04c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Civi/DataProcessor/Output/AbstractApi.php
View file @
0d0c3798
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment