OEModule\OphCoCvi\components\OphCoCvi_Manager::getEventElements PHP Method

getEventElements() public method

NB The inserted elements may be removed in the view context if the user still doesn't have the right to manage the data for that specific element.
public getEventElements ( Event $event, boolean $for_editing = false ) : array | BaseEventTypeElement[]
$event Event
$for_editing boolean
return array | BaseEventTypeElement[]
    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;
        }
    }