/** * View calendar * * @Route("/view/{id}", name="oro_calendar_view", requirements={"id"="\d+"}) * * @Template * @Acl( * id="oro_calendar_view", * type="entity", * class="OroCalendarBundle:Calendar", * permission="VIEW", * group_name="" * ) */ public function viewAction(Calendar $calendar) { /** @var SecurityFacade $securityFacade */ $securityFacade = $this->get('oro_security.security_facade'); /** @var CalendarDateTimeConfigProvider $calendarConfigProvider */ $calendarConfigProvider = $this->get('oro_calendar.provider.calendar_config'); $dateRange = $calendarConfigProvider->getDateRange(); $result = array('event_form' => $this->get('oro_calendar.calendar_event.form')->createView(), 'user_select_form' => $this->get('form.factory')->createNamed('new_calendar_owner', 'oro_user_select', null, array('autocomplete_alias' => 'acl_users', 'configs' => array('entity_id' => $calendar->getId(), 'entity_name' => 'OroCalendarBundle:Calendar', 'excludeCurrent' => true, 'extra_config' => 'acl_user_autocomplete', 'permission' => 'VIEW', 'placeholder' => 'oro.calendar.form.choose_user_to_add_calendar', 'result_template_twig' => 'OroUserBundle:User:Autocomplete/result.html.twig', 'selection_template_twig' => 'OroUserBundle:User:Autocomplete/selection.html.twig'), 'grid_name' => 'users-select-grid-exclude-owner', 'random_id' => false, 'required' => true))->createView(), 'entity' => $calendar, 'calendar' => array('selectable' => $securityFacade->isGranted('oro_calendar_event_create'), 'editable' => $securityFacade->isGranted('oro_calendar_event_update'), 'removable' => $securityFacade->isGranted('oro_calendar_event_delete'), 'timezoneOffset' => $calendarConfigProvider->getTimezoneOffset()), 'startDate' => $dateRange['startDate'], 'endDate' => $dateRange['endDate']); return $result; }
/** * Gets UID of a calendar this event belongs to * The calendar UID is a string includes a calendar alias and id in the following format: {alias}_{id} * * @return string|null */ public function getCalendarUid() { if ($this->calendar) { return sprintf('%s_%d', Calendar::CALENDAR_ALIAS, $this->calendar->getId()); } elseif ($this->systemCalendar) { $alias = $this->systemCalendar->isPublic() ? SystemCalendar::PUBLIC_CALENDAR_ALIAS : SystemCalendar::CALENDAR_ALIAS; return sprintf('%s_%d', $alias, $this->systemCalendar->getId()); } return null; }