Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function sendMessage($text, UserInterface $user, \Twig_Template $twigTemplate, array $parameters)
 {
     if ($user instanceof PhoneAwareUserInterface) {
         if (!$user->getPhone()) {
             return false;
         }
         $ret = $this->alpha->sendSms($user->getPhone(), $text);
         return !$ret->getErrors();
     }
     return 0;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function sendMessage($text, UserInterface $user, \Twig_Template $twigTemplate, array $parameters)
 {
     if ($user instanceof EmailAwareUserInterface) {
         if (!$user->getEmail()) {
             return false;
         }
         $subject = $twigTemplate->renderBlock('subject', $parameters);
         if (!$subject) {
             throw new \Exception('Subject not defined');
         }
         $body = $twigTemplate->renderBlock('body_email_text', $parameters);
         $emailMessage = \Swift_Message::newInstance();
         $emailMessage = $emailMessage->setSubject($subject)->setFrom($this->sender)->setTo($user->getEmail())->setBody($body);
         /** @var \Swift_Message $emailMessage */
         $emailMessage = $emailMessage->addPart($text, 'text/html');
         return $this->mailer->send($emailMessage);
     }
     return null;
 }