public function getEventElements(\Event $event, $for_editing = false)
{
if (!$for_editing) {
return $event->getElements();
} else {
$default = $event->eventType->getDefaultElements();
$current = $event->getElements();
if (count($current) == $default) {
// assume a match implies all the elements are already recorded for the event.
return $current;
}
$editable = array();
foreach ($default as $el) {
// check there's something in the current list as might be the last default elements that are not defined
if (isset($current[0]) && get_class($el) == get_class($current[0])) {
// the order should be consistent across default and current.
$editable[] = array_shift($current);
} else {
$editable[] = $el;
}
}
return $editable;
}
}