mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-10 14:18:25 +00:00
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\MainBundle\Service\Notifier;
|
|
|
|
use Psr\Log\LoggerInterface;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
use Symfony\Component\Notifier\Event\SentMessageEvent;
|
|
|
|
final readonly class SentMessageEventSubscriber implements EventSubscriberInterface
|
|
{
|
|
public function __construct(
|
|
private LoggerInterface $notifierLogger, // will be send to "notifierLogger" if it exists
|
|
) {}
|
|
|
|
public static function getSubscribedEvents()
|
|
{
|
|
return [
|
|
SentMessageEvent::class => ['onSentMessage', 0],
|
|
];
|
|
}
|
|
|
|
public function onSentMessage(SentMessageEvent $event): void
|
|
{
|
|
$message = $event->getMessage();
|
|
|
|
if (null === $message->getMessageId()) {
|
|
$this->notifierLogger->info('[sms] a sms message did not had any id after sending.', ['validReceiversI' => $message->getOriginalMessage()->getRecipientId()]);
|
|
} else {
|
|
$this->notifierLogger->warning('[sms] a sms was sent', ['validReceiversI' => $message->getOriginalMessage()->getRecipientId(), 'idsI' => $message->getMessageId()]);
|
|
}
|
|
}
|
|
}
|