mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
bootstrap fake sms from cli
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\BudgetBundle\Templating\Twig;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Service\Mailer\ShortMessage;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
|
||||
class DefaultShortMessageForCalendarBuilder implements ShortMessageForCalendarBuilderInterface
|
||||
{
|
||||
private ?array $config = null;
|
||||
|
||||
private EngineInterface $engine;
|
||||
|
||||
public function __construct(
|
||||
ParameterBagInterface $parameterBag,
|
||||
EngineInterface $engine
|
||||
) {
|
||||
$this->config = $parameterBag->get('chill_calendar.short_messages');
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
public function buildMessageForCalendar(Calendar $calendar): array
|
||||
{
|
||||
if (null === $this->config || true !== $calendar->getSendSMS()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$toUsers = [];
|
||||
|
||||
foreach ($calendar->getPersons() as $person) {
|
||||
if (false === $person->getAcceptSMS() || null === $person->getAcceptSMS() || null === $person->getMobilenumber()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$toUsers[] = new \Chill\MainBundle\Service\ShortMessage\ShortMessage(
|
||||
$this->engine->render('@ChillCalendar/CalendarShortMessage/short_message.txt.twig', ['calendar' => $calendar]),
|
||||
$person->getMobilenumber()
|
||||
);
|
||||
}
|
||||
|
||||
return $toUsers;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CalendarBundle\Service\ShortMessageNotification;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\MainBundle\Service\Mailer\ShortMessage;
|
||||
|
||||
interface ShortMessageForCalendarBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @param Calendar $calendar
|
||||
* @return array|ShortMessage[]
|
||||
*/
|
||||
public function buildMessageForCalendar(Calendar $calendar): array;
|
||||
}
|
Reference in New Issue
Block a user