private function sortCalendars($calendars)
    {
        $calendarsSorted = array();
        foreach ($calendars as $calendar) {
            $calendarsSorted[$calendar->id] = $calendar;
            $calendarsSorted[$calendar->id]->week_pattern = (array) $calendarsSorted[$calendar->id]->week_pattern;
        }

        return $calendarsSorted;
    }