getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, ['addAge' => false]))->toArray() ); $content = $this->twig->render('@ChillZimbra/ZimbraComponent/calendar_content.txt.twig', ['calendar' => $calendar]); } elseif ($calendar instanceof Invite) { $subject = '[Chill] '. '('.$this->translator->trans('remote_calendar.calendar_invite_statement_in_calendar').') '. implode( ', ', $calendar->getCalendar()->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, ['addAge' => false]))->toArray() ); $content = $this->twig->render('@ChillZimbra/ZimbraComponent/invitation_content.txt.twig', ['calendar' => $calendar->getCalendar()]); } else { // $calendar is an instanceof CalendarRange $subject = $this->translator->trans('remote_calendar.calendar_range_title'); $content = ''; } if ($calendar instanceof Invite) { $startDate = $calendar->getCalendar()->getStartDate(); $endDate = $calendar->getCalendar()->getEndDate(); $location = $calendar->getCalendar()->getLocation(); $hasLocation = $calendar->getCalendar()->hasLocation(); $isPrivate = $calendar->getCalendar()->getAccompanyingPeriod()?->isConfidential() ?? false; } elseif ($calendar instanceof Calendar) { $startDate = $calendar->getStartDate(); $endDate = $calendar->getEndDate(); $location = $calendar->getLocation(); $hasLocation = $calendar->hasLocation(); $isPrivate = $calendar->getAccompanyingPeriod()?->isConfidential() ?? false; } else { // Calendar range case $startDate = $calendar->getStartDate(); $endDate = $calendar->getEndDate(); $location = $calendar->getLocation(); $hasLocation = $calendar->hasLocation(); $isPrivate = false; } $comp = new InviteComponent(); $comp->setName($subject); $comp->setDescription($content); $comp->setFreeBusy(FreeBusyStatus::BUSY); $comp->setStatus(InviteStatus::CONFIRMED); $comp->setCalClass($isPrivate ? InviteClass::PRI : InviteClass::PUB); $comp->setTransparency(Transparency::OPAQUE); $comp->setIsAllDay(false); $comp->setIsDraft(false); $comp->setDtStart($this->dateConverter->phpToZimbraDateTime($startDate)); $comp->setDtEnd($this->dateConverter->phpToZimbraDateTime($endDate)); if ($hasLocation) { $comp ->setLocation($this->createLocationString($location)); } return $comp; } private function createLocationString(Location $location): string { $str = ''; if ('' !== ($loc = (string) $location->getName())) { $str .= $loc; } if ($location->hasAddress()) { if ('' !== $str) { $str .= ', '; } $str .= $this->addressRender->renderString($location->getAddress(), ['separator' => ', ']); } return $str; } }