Prepare the date to be added to the JobItem.
Right now JobItem looks for ['#text'] so if we send our structure it will add as translation text our original text, so we are replacing ['#text'] with ['#translation']['#text']
array $data: The data items.
array Returns the data items ready to be added to the JobItem.
protected function prepareData(array $data) {
if (isset($data['#text'])) {
if (isset($data['#translation']['#text'])) {
$result['#text'] = $data['#translation']['#text'];
}
else {
$result['#text'] = '';
}
return $result;
}
foreach (Element::children($data) as $key) {
$data[$key] = $this
->prepareData($data[$key]);
}
return $data;
}