Calendar::duplicate PHP Method

duplicate() public method

Clone a calendar to another entity : name is updated
public duplicate ( $options = [] )
$options array of new values to set
    function duplicate($options = array())
    {
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                if (isset($this->fields[$key])) {
                    $this->fields[$key] = $val;
                }
            }
        }
        $input = $this->fields;
        $oldID = $input['id'];
        unset($input['id']);
        if ($newID = $this->add($input)) {
            Calendar_Holiday::cloneCalendar($oldID, $newID);
            CalendarSegment::cloneCalendar($oldID, $newID);
            $this->updateDurationCache($newID);
            return true;
        }
        return false;
    }