phoneUtil = PhoneNumberUtil::getInstance(); } /** * @return list * * @throws \Twig\Error\LoaderError * @throws \Twig\Error\RuntimeError * @throws \Twig\Error\SyntaxError */ public function buildMessageForCalendar(Calendar $calendar): array { if (true !== $calendar->getSendSMS()) { return []; } $toUsers = []; foreach ($calendar->getPersons() as $person) { if (false === $person->getAcceptSMS() || null === $person->getAcceptSMS() || null === $person->getMobilenumber()) { continue; } if (Calendar::SMS_PENDING === $calendar->getSmsStatus()) { $toUsers[] = new SmsMessage( $this->phoneUtil->format($person->getMobilenumber(), PhoneNumberFormat::E164), $this->engine->render('@ChillCalendar/CalendarShortMessage/short_message.txt.twig', ['calendar' => $calendar]), ); } elseif (Calendar::SMS_CANCEL_PENDING === $calendar->getSmsStatus()) { $toUsers[] = new SmsMessage( $this->phoneUtil->format($person->getMobilenumber(), PhoneNumberFormat::E164), $this->engine->render('@ChillCalendar/CalendarShortMessage/short_message_canceled.txt.twig', ['calendar' => $calendar]), ); } } return $toUsers; } }