$data,
];
array_multisort(...
$sortArray);
// Add end time to each element
array_walk($data,
static function D&
$row) { $row['end'
] =
$row['start'
] +
$row['duration'
];
});
// Group it
$data =
$this->
structureTimelineData($data);
return $data;
} /**
* Arranges the already sorted timeline data into a parent => child structure.
*/
protected function structureTimelineData(array
$elements): array
{ // We define ourselves as the first element of the array
$element =
array_shift($elements);