/** * @param string $event * @param NotificationMessageInterface $message */ public function sendNotification($event, NotificationMessageInterface $message) { /** @var EntityRepository $repository */ $repository = $this->entityManager->getRepository('CSBillUserBundle:User'); $message->setUsers($repository->findAll()); $notification = new ChainedNotification(); $settings = $this->settings->get(sprintf('notification.%s', $event)); if ($settings['email']) { $notification->addNotifications($this->factory->createEmailNotification($message)); } if ($settings['hipchat']) { $notification->addNotifications($this->factory->createHipchatNotification($message)); } if ($settings['sms']) { foreach ($message->getUsers() as $user) { if (null === $user->getMobile()) { continue; } $notification->addNotifications($this->factory->createSmsNotification($user->getMobile(), $message)); } } $this->notification->trigger($notification); }
/** * @param string $cellphone * @param NotificationMessageInterface $message * * @return NotificationInterface */ public function createSmsNotification($cellphone, NotificationMessageInterface $message) { return new TwilioNotification($cellphone, $message->getTextContent($this->templating)); }