public function it_send_email(Rental $rental, SystemMailer $systemMailer)
 {
     $message = 'Test email';
     $locale = 'es';
     $systemMailer->send($message, ['rental' => $rental], $locale)->shouldBeCalled();
     $this->sendEmail($rental, $message, $locale);
 }
 /**
  * {@inheritdoc}
  */
 public function process(ConsumerEvent $event)
 {
     $model = $event->getMessage();
     /** @var \Sententiaregum\User\Domain\User $user */
     $user = $model->getValue('user');
     if (null === $user) {
         throw new InvalidParameterException('The "user" parameter is required for the email to send!');
     }
     $emailContent = $model->getValue('content');
     $emailConfig = $model->getValue('config_path');
     $templateParams = $model->getValue('parameters', []);
     $useDefaultEmail = null === $emailConfig;
     if (null === $emailContent && $useDefaultEmail) {
         throw new InvalidParameterException('In order to send an email properly, the parameters "content" or "config_path" are required!');
     }
     $templateParams['user'] = $user;
     $config = $useDefaultEmail ? 'SententiaregumApp:notification' : $emailConfig;
     if ($useDefaultEmail) {
         $templateParams['content'] = $emailContent;
     }
     $locale = $model->getValue('override_locale', false) ? $user->getSimpleProfile()->getLocale() : null;
     $this->mailer->send($config, $templateParams, $locale);
 }
Example #3
0
 public function sendEmail(Rental $rental, $message, $locale = 'es')
 {
     $this->systemMailer->send($message, ['rental' => $rental], $locale);
 }