engine = $engine; } 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 ShortMessage( $this->engine->render('@ChillCalendar/CalendarShortMessage/short_message.txt.twig', ['calendar' => $calendar]), $person->getMobilenumber(), ShortMessage::PRIORITY_LOW ); } elseif (Calendar::SMS_CANCEL_PENDING === $calendar->getSmsStatus()) { $toUsers[] = new ShortMessage( $this->engine->render('@ChillCalendar/CalendarShortMessage/short_message_canceled.txt.twig', ['calendar' => $calendar]), $person->getMobilenumber(), ShortMessage::PRIORITY_LOW ); } } return $toUsers; } }