Skip to content

Commit

Permalink
Merge pull request #212 from field-interactive/master
Browse files Browse the repository at this point in the history
Opportunity to give multiple recipients for swift_mail reporter.
  • Loading branch information
kbond authored Jul 10, 2019
2 parents 81e2034 + f98b6c8 commit 7a3bc24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ public function getConfigTreeBuilder()
->arrayNode('mailer')
->canBeEnabled()
->children()
->scalarNode('recipient')->isRequired()->cannotBeEmpty()->end()
->arrayNode('recipient')
->isRequired()->cannotBeEmpty()
->prototype('scalar')->end()
->beforeNormalization()
->ifString()
->then(function ($v) { return array($v); })
->end()
->end()
->scalarNode('sender')->isRequired()->cannotBeEmpty()->end()
->scalarNode('subject')->isRequired()->cannotBeEmpty()->end()
->booleanNode('send_on_warning')->defaultTrue()->end()
Expand Down
10 changes: 5 additions & 5 deletions Helper/SwiftMailerReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
class SwiftMailerReporter implements ReporterInterface
{
private $mailer;
private $recipient;
private $recipients;
private $subject;
private $sender;
private $sendOnWarning;

/**
* @param Swift_Mailer $mailer
* @param string $recipient
* @param string|array $recipients
* @param string $sender
* @param string $subject
* @param bool $sendOnWarning
*/
public function __construct(Swift_Mailer $mailer, $recipient, $sender, $subject, $sendOnWarning = true)
public function __construct(Swift_Mailer $mailer, $recipients, $sender, $subject, $sendOnWarning = true)
{
$this->mailer = $mailer;
$this->recipient = $recipient;
$this->recipients = $recipients;
$this->sender = $sender;
$this->subject = $subject;
$this->sendOnWarning = $sendOnWarning;
Expand Down Expand Up @@ -107,7 +107,7 @@ private function sendEmail(ResultsCollection $results)
$message = (new Swift_Message())
->setSubject($this->subject)
->setFrom($this->sender)
->setTo($this->recipient)
->setTo($this->recipients)
->setBody($body);

$this->mailer->send($message);
Expand Down

0 comments on commit 7a3bc24

Please sign in to comment.