in core/ServerEventAsyncTask.php [99:126]
protected function prepare_data($data) {
try {
if (!empty($data)) {
$num_events = $data[1];
$events = $data[0];
// $data[0] can be a single event or an array
// We want to receive it as an array
if($num_events == 1){
$events = array($events);
}
// Each event is casted to a php array with normalize()
$events_as_array = array();
foreach($events as $event){
$events_as_array[] = $event->normalize();
}
// The array of events is converted to a JSON string
// and encoded in base 64
return array(
'event_data' => base64_encode(json_encode($events_as_array)),
'num_events'=>$data[1]
);
}
} catch (\Exception $ex) {
error_log($ex);
}
return array();
}