Ejemplo n.º 1
0
 /**
  * Returns all calendars.
  *
  * @param string|null $indexBy
  * @return array
  */
 public function getAllCalendars($indexBy = null)
 {
     if (!$this->_fetchedAllCalendars) {
         $calendarRecords = Events_CalendarRecord::model()->ordered()->findAll();
         $this->_calendarsById = Events_CalendarModel::populateModels($calendarRecords, 'id');
         $this->_fetchedAllCalendars = true;
     }
     if ($indexBy == 'id') {
         return $this->_calendarsById;
     } else {
         if (!$indexBy) {
             return array_values($this->_calendarsById);
         } else {
             $calendars = array();
             foreach ($this->_calendarsById as $calendar) {
                 $calendars[$calendar->{$indexBy}] = $calendar;
             }
             return $calendars;
         }
     }
 }