예제 #1
0
 /**
  * @param bool $isNew
  *
  * @return array key = calendarUid, value = calendar name
  */
 protected function getChoices($isNew)
 {
     $calendars = $this->calendarEventManager->getSystemCalendars();
     if ($isNew && count($calendars) === 1) {
         $calendars[0]['name'] = $this->translator->trans('oro.calendar.add_to_calendar', ['%name%' => $calendars[0]['name']]);
     } elseif (!$isNew || count($calendars) !== 0) {
         usort($calendars, function ($a, $b) {
             return strcasecmp($a['name'], $b['name']);
         });
         $userCalendars = $this->calendarEventManager->getUserCalendars();
         foreach ($userCalendars as $userCalendar) {
             $userCalendar['alias'] = Calendar::CALENDAR_ALIAS;
             array_unshift($calendars, $userCalendar);
         }
     }
     $choices = [];
     foreach ($calendars as $calendar) {
         $alias = !empty($calendar['alias']) ? $calendar['alias'] : ($calendar['public'] ? SystemCalendar::PUBLIC_CALENDAR_ALIAS : SystemCalendar::CALENDAR_ALIAS);
         $calendarUid = $this->calendarEventManager->getCalendarUid($alias, $calendar['id']);
         $choices[$calendarUid] = $calendar['name'];
     }
     return $choices;
 }
예제 #2
0
 public function testGetCalendarUid()
 {
     $this->assertEquals('test_123', $this->manager->getCalendarUid('test', 123));
 }